PDA

View Full Version : Grid Default Sorting



edinho77
3 Aug 2009, 9:31 AM
I'm having a problem with the default sorting of a grid. The grid is showing information sorting it with 'date ASC' instead of 'date DESC'.
If I check the response from the server the information is ordered 'date DESC'.

The problem appeared when I upgraded the extjs version from 2.2 to 3.0.

Below is part of the code. Please, let me know if I should post more information.



// The main grid's store
var taskStore = new Ext.data.GroupingStore({
sortInfo:{field: 'date', direction: "DESC"},
groupField:'date',
id: 'horasCargadasDataStore',
proxy: taskProxy,
baseParams:{task: "LISTING"},
remoteSort: true,
reader: ajaxReader
});

// The main grid with all it's configuration options
var grid = new xg.EditorGridPanel({
id:'tasks-grid',
store: taskStore,
sm: selections,
enableColumnHide:false,
enableColumnMove:false,
border:false,
title:'Registro Multiple',
iconCls:'icon-show-all',
region:'center',
loadMask:{msg: 'Cargando datos...',removeMask:true},
listeners : {
render : function(){
this.loadMask.show();
var store = this.getStore();
store.load.defer(100,store, [ {params:{a:1, b:2 } }]);
},
delay: 100
},
plugins: [
summary,
completeColumn
],
columns: [
{
header: "idCarga",
width:0,
hidden: true,
sortable: false,
dataIndex: 'taskId',
editor: new Ext.form.NumberField({
hidden: true
})
},
{
header: "Fecha Registro",
width:94,
sortable: true,
dataIndex: 'date',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
validationDelay: 0,
groupRenderer: textDate(),
groupName: 'Día',
align: 'center',
editor: rowFecReg
},
{
header: "ID Proy.",
width:46,
sortable: true,
dataIndex: 'project',
align: 'right'
},
{
header: "Nombre Proyecto",
width:140,
sortable: true,
dataIndex: 'pro_name'
},
{
header: "ID Tarea",
width:54,
sortable: true,
dataIndex: 'task',
align: 'right',
editor: idDeTarea
},
{
header: "Nombre Tarea",
width:140,
sortable: true,
dataIndex: 'tas_name'
},
{
header: "idCuenta",
width:96,
hidden: true,
sortable: true,
dataIndex: 'cue_id',
editor: new Ext.form.NumberField({
hidden: true
})
},
{
header: "Cuenta",
width:135,
sortable: true,
dataIndex: 'cuenta'/*,
editor: new Ext.form.ComboBox({
minListWidth: 400,
listClass:'x-combo-list-small',
valueField: 'id',
displayField: 'nombre',
triggerAction: 'all',
mode:'local',
editable: false,
store: cuentasStore,
allowBlank: false
})*/
},
{
header: "Hora Inicio",
width:60,
sortable: true,
dataIndex: 'hora-inicio',
id: 'hora-inicio',
align: 'right',
editor: rowHoraInicio
},
{
header: "Hora Fin",
width:55,
sortable: true,
dataIndex: 'hora-fin',
align: 'right',
editor: rowHoraFin
},
{
header: "Horas",
width:40,
sortable: true,
dataIndex: 'hours',
summaryType:'sum',
renderer: function(val){
if(typeof val.toFixed == 'function') {
return val.toFixed(2);
}else{
return val;
}
},
align: 'right',
editor: rowHoras
},
{
header: "Comentario Carga",
width: 130,
sortable: true,
dataIndex: 'comments',
editor: rowComentario
},
completeColumn
],

view: new Ext.grid.GroupingView({
forceFit:true,
ignoreAdd: true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Tareas" : "Tarea"]})',
templates: {
header: headerTpl
},
enableRowBody:true,
showPreview: false,
getRowClass : function(record, rowIndex, p, taskStore){
if(record.data.idSolicitud != ''){
p.body = '<p>Solicitud asociada: '+record.data.idSolicitud+' - "'+record.data.sol_nombre+'"</p>';
}else{
p.body = '<p>Solicitud asociada: Sin solicitud asociada</p>';
}
if(this.showPreview){
return 'x-grid3-row-expanded';
}
return 'x-grid3-row-collapsed';
}
})
});
Thanks for your help.

mjlecomte
3 Aug 2009, 10:05 AM
What if you comment out this line:


// The main grid's store
var taskStore = new Ext.data.GroupingStore({
// sortInfo:{field: 'date', direction: "DESC"},
groupField:'date',
id: 'horasCargadasDataStore',
proxy: taskProxy,
baseParams:{task: "LISTING"},
remoteSort: true,
reader: ajaxReader
});

mjlecomte
3 Aug 2009, 10:06 AM
FYI, for purposes of getting help, it would be better if you found an existing demo example and modified it to reproduce your problem. As it is now I can't test the code you're having problems with. If you posted a modification to an existing demo I could easily cut/paste it locally and run it.

edinho77
3 Aug 2009, 10:45 AM
If I comment that line the console output is:

this.sortInfo is undefined

I'll try to reproduce my problem in an existing example.