Jaydeep
Jaydeep

Reputation: 456

Jqgrid After setting width of column, and then try to click column separator causes the column resize back to the newWidth

Here i am having problem with grid column resize. The actual functionality i want to achieve is that i want to reset the grid column widths to some default values on click of buttons. I successfully changed the width of column using some code, but the problem is arise now. The problem is after resetting the column widths (i.e. setting column width) and then when i Just click on column separator causes column width change to previously set width (i.e. newwidth).

I illustrate the problem by showing images. Just consider the images in sequence as they shown.

1. Before resizing the column. enter image description here

2. After resizing the column. enter image description here

3. Now reset width to default width. enter image description here

4. Now just click on separator. This will cause the column to be resized again to previous state before we reset. and also causes undesired behavior when dragging as you see in next pic. enter image description here

5. Width increased and undesired behavior when dragging. enter image description here

I tried many things. I also found this : jQuery grid plugin - triand But unfortunately no solution provided in it.

By using that reference, i tried to setting newWidth to 0, -1, undefined and moreover i removed it from headers. but all the things not working.

I can't understand what is happening. Please note that there is no chance that some undesired code in project resided somewhere else causes this behavior. For the test i tried using new version of jqgrid 4.5.1, but in that also happening the same.

Please someone provide me solution for this. I am tired as i am doing this thing from many days. I am very much thankful to the one who help me.

Thank You in Advance !

Upvotes: 1

Views: 660

Answers (1)

Oleg
Oleg

Reputation: 222017

I am not sure how you implemented "reset width to default width", but I hope two things should help you.

First of all jqGrid have bug in resizing of columns which looks exactly like on the "Step 5" which you described. I posted the pull request which merged to the main code of jqGrid about one month ago. You can do the same changes (two lines need be change) you your copy of jquery.jqGrid.src.js (see here details of the changes).

To implement resetting of width of columns to default width you can use the following. First you can use widthOrg of elements of colModel. After resizing of any column the original value of width will be saved in widthOrg. To change the column width one can use setColWidth method which I suggested in the resent answer.

I hope you will able to solve you problem using widthOrg, setColWidth and the bug fix bescribed above.

Upvotes: 1

Related Questions