Disable auto sorting on property grid in ExtJS

Fatih Acet picture Fatih Acet · Dec 3, 2010 · Viewed 11k times · Source

I am dealing with property grid. I want to prevent auto sorting of column names for property grid. here is my code. Bold highlighted code is my source for property grid and its order is just like I want to see. But Ext is auto sorting column orders alphabeticly. How can I prevent that.

Thanks for any suggestion.

Ext.ns('Application.propertygrid');
Application.propertygrid.FileDetail = Ext.extend(Ext.grid.PropertyGrid, {
    title: 'File Detail',
    height: 200,
    border: false,
    stripeRows: true,
    flex: 1,
    initComponent: function () {
        Application.propertygrid.FileDetail.superclass.initComponent.apply(this, arguments);
    },
    source: {
        Name: 'Please select a file',
        Type: 'Please select a file',
        Size: 'Please select a file',
        Path: 'Please select a file',
        FullPath: 'Please select a file',
        Width: 'Please select a file',
        Height: 'Please select a file'
    },
    listeners: {
        beforeedit: function(){
            return false; // prevent editing 
        },
        headerclick: function(){
            return false; // prevent column sorting on click
        }
    }
})
Ext.reg('filedetail', Application.propertygrid.FileDetail);

Answer

Fatih Acet picture Fatih Acet · Dec 4, 2010

Yeah. I've done with it. And here is the solution.

var p = new Ext.grid.PropertyGrid({
  ...
  // do not specify 'source' here
});

delete p.getStore().sortInfo; // Remove default sorting
p.getColumnModel().getColumnById('name').sortable = false; // set sorting of first column to false
p.setSource(source); // Now load data