views:

87

answers:

2

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

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

Gregg
We do want that column to be sortable - we just don't want the sort icon appearing on that column by default. If we set sortable:false then our users can't sort on the column..
Marcus
I don't know that there is a way in the jqGrid API directly, but you could do this after the grid is finished loading: $('.a-ico').hide();
Gregg
+1  A: 

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.

Oleg
With row numbers this does work on initial load (no sort icon). If you then sort on a column header the icons appear (which is good). But if you reload the grid the icons still appear - how can you get the icons to disappear when you run `grid.trigger("reloadGrid")`?
Marcus
I tried running `grid.setGridParam({sortname:'', sortorder:''}); ` prior to the grid reload but this didn't work either..
Marcus
@Marcus: Do use seen that yesterday I wrote UPDATED part? Do you tried to use `rownumbers:true` and if you not really need the row number column disable it with `$("#list").jqGrid('hideCol','rn')`. It works perfect at me: see http://www.ok-soft-gmbh.com/jqGrid/SortIcon.htm
Oleg
It works - issue I had is when I reload the grid (using grid.trigger("reload") and not an entire page refresh) the sort icon doesn't reset.
Marcus
@Marcus: I don't understand what you exactly mean. You should describe exactly the scenario which you have: what you have before starting ` grid.trigger("reloadGrid")` (for example a column sorted or not) what is the expected results after reloading and what you see. What code do you use. Can you modify my example http://www.ok-soft-gmbh.com/jqGrid/SortIcon.htm so that your problem can be reproduced? You can any time place sorting on the 'rn' column if you need.
Oleg
I load the grid and there is no sort icon. Then I sort and the icon appears. Then I call trigger(reloadGrid) - what I want is for the sort icon to go away after the reload. But the sort icon is unchanged.
Marcus