Don't want to show sorting icon for the first

2019-02-16 01:39发布

问题:

I am using jqGrid and loading data through JSON. for the very first time when I get the data I sort that using custom method and pass that data to grid. But it always display sorting icon on the first column which I don't want to show because custom method sort the data using several calculations but when sorting icon appears on first column then a wrong message goes to the user.

I can not user rownumbers as it sorts data on row numbering, tried CSS to display:none but that hide the icon permanently.

icon should only be displayed if someone clicks any or the sortable header.

Can someone help?

回答1:

The problem could exist if you don't use rownumbers: true or some other options which adds one more first columns in the grid. As a workaround you can use the following option

lastsort: "0"

It's important to use the value of lastsort as string and not as number (lastsort: "0" and not as lastsort: 0 which is default).

UPDATED: I posted the pull request which suggest modification of jqGrid code to eliminate the problem which you describe.

UPDATED 2: The pull request is merged today to the main code of jqGrid on github. So the next version of jqGrid (higher as 4.6.0) which will be published should not have the problem which you described.



回答2:

I searched a lot for the answer on the net as well as on the official site of jqGrid but unfortunately could not find anything helpful.

Now I am going with a hack to solve the issue and that is adding a blank column at the first place and make that hidden.

colNames: ["", "Student name", "Course"],
colModel: [
                {
                    name: '',
                    index: '',
                    hidden: false

                }, { 
                     name: 'student_name',
                     index: 'student_name',
                }, {
                     name: 'course',
                     index: 'course'
      ]

If someone get something helpful then please do post.



标签: jqgrid