不执行排序时显示jqGrid排序图标 [英] jqGrid sort icon displayed when no sorting performed

查看:103
本文介绍了不执行排序时显示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时完全相同的网格,而且在第一列的标题上也没有排序图标.

更新:答案中介绍了另一种解决方法和错误修复. /p>

In our grid we do not have sortName or sortOrder defined but the first column has the sort icon displayed (in ASC order). How can you prevent the sort icon from appearing?


Update: Code below

  $("#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
    }
  });

解决方案

I modified a code example which you already know and commented sortname and sortorder. Now we have a grid with no sort icon displayed like you want. Look at here. You can also use sortname:id as an another option with the same result. So if the behavior of your grid is another one: post a code example.

UPDATED: After you post an example everything is clear. I use rownumbers:true in all my grids just I like it. If you add the option rownumbers:true to your grid you will see no sorting icon on the header of the first column. If you do not need the row number column you can use

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

to hide it. As a result you will have exactly the same grid as without rownumbers:true, but also without sorting icon on the header of the first column.

UPDATED: One more workaround and the bug fix are described in the answer.

这篇关于不执行排序时显示jqGrid排序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆