PDA

View Full Version : Default Sort is not Working in ext3.x



amitru
1 Dec 2011, 1:55 AM
Hello,

DefaultSort is not working below is the snipp, please advise.

<html>

<script type="text/javascript" src="../lib/ext-base.js"></script>
<script type="text/javascript" src="../lib/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="../css/ext-all.css" />


<script language="javascript">

Ext.onReady(function()
{
Ext.QuickTips.init();
Ext.data.Types.FLOATORSTRING = {
convert: function(v, n) {
return n;
},
sortType: function(v) {
v = Ext.isNumber(v) ? v : parseFloat(String(v), 10);
return isNaN(v) ? -999999 : v;
},
type: 'floatOrString'
};

var myGridPanel = new Ext.grid.GridPanel({
id: 'testGridForSort',
title: 'Assoc Docs',
//applyTo: 'myDiv',
width: 200,
height: 200,
viewConfig :{
forceFit:false,
emptyText:'No rows to display' //Check for no rows
},
store: new Ext.data.ArrayStore({
fields: [{name: 'field1', type: 'floatOrString',mapping: 'field1'}],
data:['-1','-','100','2','124','-','70','145','zzbcd','pqr','azz']
//sortInfo: { field: "field1", direction: "ASC" }
}),
columns: [{header: 'Sort me', dataIndex: 'field1', sortable: true}],
buttons: [{
text: 'Search',handler : function(){}
}, {
text: 'Clear',handler : function(){}
}]
});

myGridPanel.getStore().setDefaultSort('field1', 'asc');
myGridPanel.render('myDiv');
});


</script>
<div id="myDiv" style="position:absolute; top:150; left:40%;">
</div>
</html>

Thanks,
Amit

mitchellsimoens
1 Dec 2011, 11:59 AM
It looks like it's sorting to me. What's wrong?