未执行排序时显示jqGrid排序图标

在我们的网格中,我们没有定义sortNamesortOrder但第一列显示了排序图标(按ASC顺序)。 如何防止排序图标出现?


更新 :以下代码

  $("#list").jqGrid({ url:'NoData.json', datatype: 'json', mtype: 'GET', colNames:['Product', 'Type','Expiry', 'Put Call', 'Strike', 'Account','Long','Short', 'Open Qty', 'LTD', 'Operations'], colModel :[ {name:'product', index:'product', width:75}, {name:'type', index:'type', width:50, align:'right'}, {name:'expiry', index:'expiry', width:60, align:'right'}, {name:'putCall', index:'putCall', width:65}, {name:'strike', index:'strike', sorttype: 'float', width:70}, {name:'account', index:'account', width:70}, {name:'long', index:'long', sorttype: 'int', width:55, align:'right'}, {name:'short', index:'short', sorttype: 'int', width:55, align:'right'}, {name: 'openQty', index:'openQty', width:80, align:'center', sortable:false, search:false, formatter:closeoutFormatter}, {name:'LTD', index:'LTD', width:65, align:'right'}, {index:'operations', width:105, title:false, search:false, align: 'center', formatter:opsFormatter, sortable:false} ], onPaging: function (b) { var nextPg = $("#list").getGridParam("page"); if (dirty == 'false') { currPg = nextPg; return; } $( "#dialog-confirm" ).dialog({ resizable: false, height:160, modal: true, buttons: { "Stay on current page": function() { $( this ).dialog( "close" ); }, "Change page": function() { $( this ).dialog( "close" ); reloadGrid($("#list"), null, nextPg, 'false'); } } }); $("#list").setGridParam({page:currPg}); //Workaround - jqGrid still increments the page num even when we return stop so we have to reset it (and track the current page num) return 'stop'; }, pager: '#pager', scrollOffset:0, //No scrollbar rowNum:15, width:'100%', viewrecords: true , caption: 'Positions', height: '360', hidegrid: false //Don't show the expand/collapse button on the top right }).navGrid("#pager",{edit:false,add:false,del:false, beforeRefresh: function(){ reloadGrid($("#list"), null, 1, 'true'); //Required so that we go to the server and not reload local data } }); 

我修改了一个你已经知道的代码示例,并对sortnamesortorder评论。 现在我们有一个网格, 没有你想要的排序图标 。 看看这里 您还可以使用sortname:id作为具有相同结果的另一个选项。 因此,如果网格的行为是另一个:发布代码示例。

更新 :发布示例后,一切都很清楚。 我使用rownumbers:true在我的所有网格中都是如此我只是喜欢它。 如果将选项rownumbers:true添加到网格中,您将在第一列的标题上看不到排序图标。 如果您不需要行号列,则可以使用

 $("#list").jqGrid("hideCol", "rn"); 

隐藏它 因此,您将拥有与没有rownumbers:true完全相同的网格rownumbers:true ,但在第一列的标题上也没有排序图标。

更新: 答案中描述了另一个解决方法和错误修复。

为该列的模型配置添加sortable:false。

虽然这是一个较老的问题。 但有一个技巧可以解决上述问题。 只需添加第一列"hidden:true" 。 如果在jqgrid属性中没有设置sortOrder和sortname,则可以使用此工作。 如果已将sortOrder设置为sortName,则将其设置为隐藏的任何列名称。 因此默认情况下不会显示排序箭头。 希望这对jqgrid有用。 谢谢。