Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable auto sorting on property grid in ExtJS

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);
like image 407
Fatih Acet Avatar asked Dec 03 '10 20:12

Fatih Acet


1 Answers

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
like image 113
Fatih Acet Avatar answered Oct 02 '22 09:10

Fatih Acet