Simple question. Is there a function to get the current sort position of a column by name in a grid?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The indexes used in the
remapColumnsmethod are the same as in thecolModelarray. It’s important to understand, that the indexes can be different as in thecolModelparameter of jqGrid used initially. If jqGrid uses optionsrownumbers: truean additional column with the name'rn'will be inserted at the first place ofcolModelarray. The indexes of all other elements ofcolModelarray will be incremented. In the same way the optionmultiselect: trueinserts the column'cb'abd the optionsubGrid: trueinserts the column'subgrid'. In the same way the optiontreeGrid: truefollows appendingcolModelarray with some additional hidden columns which names can be defined bytreeReader. The default names of the columns in case oftreeGridModel: 'nested'are:'level','lft','rgt','isLeaf','expanded','loaded'and'icon'or'level','parent','isLeaf','expanded','loaded'and'icon'in case oftreeGridModel: 'adjacency'.So to find the index of the column by the name you should just get the current
colModel, look through the items and find the item where'name'property are the column name which you need. To getcolModelyou can use$("#grid")[0].p.colModelor$("#grid").jqGrid('getgridParam', 'colModel'). So the code can be like the following:and the usage like
To get the name of the current sorted column you can use
$grid.jqGrid('getGridParam', 'sortname')