PDA

View Full Version : Disable auto sorting on property grid



extDev
3 Dec 2010, 9:48 AM
Hi folks,

I am dealing with property grid. I want to prevent auto sorting of column names for property grid.
here is my code. Red highlighted is my source 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);

extDev
3 Dec 2010, 10:12 AM
Also, I would like to point on this, I am trying to disable the sorting before grid render.

darthwes
3 Dec 2010, 3:20 PM
Um propertygrids have column models. You go



cm: new Ext.grid.ColumnModel({
defaults: {
sortable: false
},
columns: [...]
})


Then the order you define in the columns array is the order used, right?

Condor
4 Dec 2010, 1:04 AM
No, unfortunately, PropertyGrid does a lot of work to shield you from the actual ColumnModel.

I would suggest:

var p = new Ext.grid.PropertyGrid({
...
// do not specify 'source' here
});
// Remove default sorting
delete p.getStore().sortInfo;
p.getColumnModel().getColumnById('name').sortable = false;
// Now load data
p.setSource(source);

extDev
4 Dec 2010, 7:25 AM
Great Master :-)
this works properly, I have added your 2 lines of code my property grid's beforerender event, it's worked but, I think doing this on beforerender is increased the grid's render time. thanks again Master. :)


No, unfortunately, PropertyGrid does a lot of work to shield you from the actual ColumnModel.

I would suggest:

var p = new Ext.grid.PropertyGrid({
...
// do not specify 'source' here
});
// Remove default sorting
delete p.getStore().sortInfo;
p.getColumnModel().getColumnById('name').sortable = false;
// Now load data
p.setSource(source);