Marcus Leon
Marcus Leon

Reputation: 56679

jqGrid sort icon displayed when no sorting performed

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
    }
  });

Upvotes: 1

Views: 5040

Answers (3)

Sanket Patel
Sanket Patel

Reputation: 1160

Although this is older question. But There is a trick that work on above question. Just add first column which is "hidden:true" . This work in case where there is no sortOrder and sortname is set in jqgrid properties. If you have set sortOrder an sortName,then set it any column name which is hidden. So sorting arrow will not display by default. Hope this is helpful tip for jqgrid. Thanks.

Upvotes: 0

Oleg
Oleg

Reputation: 221997

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.

Upvotes: 2

Gregg
Gregg

Reputation: 35864

Add sortable:false to that column's model config.

Upvotes: 0

Related Questions