ce icon indicating copy to clipboard operation
ce copied to clipboard

The position of Frozen columns is incorrect if .hideIndex() is used.

Open kunalshewale opened this issue 5 years ago • 11 comments

Hi,

While working on my requirement I observed that the position of the frozen column is not set correctly if your index number column is hidden. I found the solution, posted it below.

obj.updateFreezePosition = function() {
            scrollLeft = obj.content.scrollLeft;
            var width = 0;
            if (scrollLeft > 50) {
                for (var i = 0; i < obj.options.freezeColumns; i++) {
                    if (i > 0) {
                        width += parseInt(obj.options.columns[i-1].width);
                    }
                    obj.headers[i].classList.add('jexcel_freezed');
                    obj.headers[i].style.left = width + 'px';
                    for (var j = 0; j < obj.rows.length; j++) {
                        if (obj.rows[j] && obj.records[j][i]) {
                            var indexColumnWidth = (obj.table.classList.contains('jexcel_hidden_index') ? 1 : 51)
                            var shifted = (scrollLeft + (i > 0 ? obj.records[j][i-1].style.width : 0)) - indexColumnWidth + 'px';
                            obj.records[j][i].classList.add('jexcel_freezed');
                            obj.records[j][i].style.left = shifted;
                        }
                    }
                }
            } else {
                for (var i = 0; i < obj.options.freezeColumns; i++) {
                    obj.headers[i].classList.remove('jexcel_freezed');
                    obj.headers[i].style.left = '';
                    for (var j = 0; j < obj.rows.length; j++) {
                        if (obj.records[j][i]) {
                            obj.records[j][i].classList.remove('jexcel_freezed');
                            obj.records[j][i].style.left = '';
                        }
                    }
                }
            }

            // Place the corner in the correct place
            obj.updateCornerPosition();
        }

kunalshewale avatar Aug 18 '20 06:08 kunalshewale

Could you list more code ,pls?I also met this problem ,thx!

whyJoe avatar Aug 20 '20 08:08 whyJoe

Could you list more code ,pls?I also met this problem ,thx!

Can you please elaborate, what exactly you want within the code?

kunalshewale avatar Aug 21 '20 16:08 kunalshewale

emmm ,i don't konw how use your solution in my code.

whyJoe avatar Aug 24 '20 02:08 whyJoe

We can't fix it from external code, we have to make the adjustment in jexcel.core.js file. The above snippet is from the respective file.

kunalshewale avatar Aug 24 '20 05:08 kunalshewale

I replaced the source code with your code directly,but it not work.So I don't konw how to do....

whyJoe avatar Aug 24 '20 08:08 whyJoe

Please see if the following helps you.

https://github.com/kunalshewale/jexcel/commit/6edc3165f90fd2dfe917cfda607e533877063107

In case you still have an issue, please share codepen link where I can take a look.

kunalshewale avatar Aug 24 '20 13:08 kunalshewale

Excure me ,can you leave a email?I don't konw how to post pictures here,hhhh

whyJoe avatar Aug 25 '20 00:08 whyJoe

I found that frozen columns not effect when I didnot set table width, dou you confused with the same question

fredchengfei avatar Sep 04 '20 05:09 fredchengfei

I found that frozen columns not effect when I didnot set table width, dou you confused with the same question

I am not sure what you are implying here. The issue was; if I have a frozen column in the table then while scrolling horizontally the position of the frozen columns were not set correctly.

kunalshewale avatar Sep 04 '20 06:09 kunalshewale

Excure me ,can you leave a email?I don't konw how to post pictures here,hhhh

Hope, the issue is resolved for you. In case it is not, please drop a message here.

kunalshewale avatar Sep 04 '20 06:09 kunalshewale

Can you update this to latest version?

0Chan-smc avatar Mar 07 '24 05:03 0Chan-smc