sprugman
sprugman

Reputation: 19831

how can I make a column unsortable when using the dojo toolkit's grid?

I've got a grid (dojox.grid v1.2) that I don't want to be sortable. How can I disable that?

Upvotes: 2

Views: 8616

Answers (4)

Parivesh Jain
Parivesh Jain

Reputation: 71

I think right solution is

dijit.byId('yourgridid').attr('canSort', function(col){

    if(Math.abs(col) == 3) {
      return false;
    } else {
       return true;
    }

});

Upvotes: 0

satish hiremath
satish hiremath

Reputation: 127

Use attribute canSort : false to hide or disable sort button in Dojo DataGrid code:

var newGrid = new DataGrid({

        id : 'newGrid',

        canSort:false,

        store : this.resultStore,

        structure : this.resultGridLayout,

        autoHeight:true
});

Regards,

Satish M Hiremath

Upvotes: 0

Austin France
Austin France

Reputation: 2511

If you are creating your grid programatically you can do the following:

var grid = new dojox.grid.DataGrid({ 
               ..., 
               canSort: function(col) { return col != 3; }
           });

Upvotes: 0

sprugman
sprugman

Reputation: 19831

Found it:

http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/disable-sorting-specific-column-0

To save linking:

In your onload, or postrender add code like this:

dojo.byId('myGridId').canSort = function(col){ if(Math.abs(col) == 3) { return false; } else { return true; } };

(Note, the columns seem to be indexed from 1 in this setting.)

Upvotes: 4

Related Questions