How to fix sync issue between column-header-width and column-body-width without the use of deprecated jqGrid updateColumns method?

戏子无情 提交于 2019-12-22 10:16:00

问题


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.

来源:https://stackoverflow.com/questions/18191543/how-to-fix-sync-issue-between-column-header-width-and-column-body-width-without

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!