How to fix sync issue between column-header-width

2019-05-14 03:24发布

Currently I am working on restoring saved grid preferences/configuration. This is more or less working beautifully, until we get to the last last step of performing that performs a column remap, $grid.jqGrid("remapColumns", perm, true, true); and what happens is that the reordered column-header-widths are out of sync with thier corresponding column-body-widths.

This remap does correctly display of both the column-header names and column-body data in the new order and based on user preferences.

However, what is wonky is the following. There are three columns: (1) Name (width: 200), (2) Id (width: 70), and (3) Alert (width: 60)

As stated the actual reorder of column headers and correspeond column body data is fine.

So that the original order:

                          Name       |  Id   | Alert
                          x          |  1    | a,c,d
                          y          |  2    | 
                          z          |  3    | c

Correctly remaps to new order, but (for purpose of visual example) as shown below the column-header-widths are out of sync with the the column-body-widths

                          Id         |  Name  | Alert
                          1  | x              | a,c,d
                          2  | y              | 
                          3  | z              | c

Each column contains the correct data, but now the following is happening with regard to the column widths.

Id column-header now has a column-header-width = 200 (incorrect width), and the Id column-body-width = 70 (correct width)

Name column-header now has a column-header-width = 70 (incorrect width) and the Name column-body-width = 200 (correct width).

Alert column is unaffected and is correctly sized width for both column-header (width = 60) and column-body (width = 60).

In working to resolve this issue, I believed that the updateColumns method was a good bet for syncing column-header-widths that were out of sync with corresponding column-body-widths. As stated here in the documentation, (http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3amethods)

updateColumns - this synchronizes the width of the headers with the data. Useful when used with table drag and drop. This method should be used this way – Example: var mygrid=jQuery("#grid_id")[0]; mygrid.updateColumns();

However, after unsuccessful attempts to use updateColumns() and then some further digging, it turns out that this method is deprecated/removed from code as of jqGrid 3.8. We are currently using jqGrid version 4.4/4.5.

(preferred) How in the world can I fix this issue using the current version of the software both with regard to syncing the column-header-widths and column-body widths?

And/or where can I find jqGrid source code 3.7 so I can take a look at this method and possibly use it? While I have found previous versions of jqGrid, I just haven't been able to find versions <= 3.7.

At this point, there really is a huge need on my end for an efficient solution and clear guidance to nip this in the bud. Please let me know if any further clarifications or code are necessary.

0条回答
登录 后发表回答