Hi Riccardo, here a code snippet I have in use: myStore.setDefaultSort('magnitudo', 'DESC'); // just after instanciating the store
Best regards, Chris Am 02.11.2011 12:16, schrieb Riccardo Gaeta: > Hi all, > I have a problem: I'm not able to set correctly the sortInfo to have > my data ordered in my GridPanel by a column. > I've spent lot of time by forum but I was not able to find a solution > for me. > I load a WFS layer from MapServer/Postgis, then I like order the data > (like 20-30 records) by date field. > My date field originally come from Postgres "timestamp", but here I > translate it as string. > Anyway I don't know why Ext order my records with this column > "full_date", in ascending order, and I'm not able to reverse this > order, or better change the field to use for order my data (like > "magnitudo", that is a double field). > > I use Ext 3.4.0, and I try my page on Chrome. > > Thanks everyone could give me a suggest!!! > > The code (the commented line are my test:they don't work): > > var sismi = new OpenLayers.Layer.Vector("Sismicità strumentale - > ultimi 15 giorni", { > styleMap: styleMap_sismi, > strategies: [new OpenLayers.Strategy.Fixed()], > protocol: new OpenLayers.Protocol.WFS({ > url: urlMS_sismi, version: "1.1.0", featureType: "sism_last15", > featureNS: "http://mapserver.gis.umn.edu/mapserver", > extractAttributes: true, extractStyles: true, geometry: "msGeometry", > srsName: "EPSG:32632" > }) > }); > var store_sismi = new GeoExt.data.FeatureStore({ > fields: [ > {name: "latitudine", type: "float"}, > {name: "longitudine", type: "float"}, > {name: "profondita", type: "float"}, > {name: "magnitudo", type: "float", mapping:"magnitudo"}, > {name: "regione_geografica", type: "string"}, > {name: "num_fasi", type: "integer"}, > {name: "max_gap_az", type: "integer"}, > {name: "localita", type: "string"}, > {name: "full_date", type: "string"} > ], > layer: sismi > //, remoteSort: false //to enable sorting from server > , sortInfo:{"field": 'magnitudo', "direction": "DESC"} //don't > work... > //, paramOrder:['magnitudo'] > }); > //store_sismi.setDefaultSort('magnitudo', 'DESC'); > //store_sismi.sort('magnitudo', "DESC"); > > gridPanel = new Ext.grid.GridPanel({ > xtype : 'grid', //a cosa serve? > title: "Elenco degli eventi sismici", > region: "south", > //stripeRows: true, > columnLines: true, > viewConfig: {forceFit: true}, > store: store_sismi, > loadMask: true, //a cosa serve? > height: Math.round(height_map*0.4), //280 > autoScroll: true, > collapsible: true, > collapsed: false, > //sm: new GeoExt.grid.FeatureSelectionModel(), //per > sincronizzare grid e features > cm: new Ext.grid.ColumnModel({ > defaults: { > sortable: true > }, > columns: [ > {header: "<b>Magnitudo [ML]</b>", dataIndex: > "magnitudo", decimalPrecision: 2, > align: "center", width: 150}, > {header: "<b>Tempo origine</b>", dataIndex: "full_date", width: 175}, > {header: "Prof. [km]", dataIndex: > "profondita", decimalPrecision: 2, align: "center"}, > {header: "Lat", dataIndex: "latitudine", > decimalPrecision: 3, align: "center"}, > {header: "Lon", dataIndex: "longitudine", > decimalPrecision: 3, align: "center"}, > {header: "Regione geografica", dataIndex: > "regione_geografica", width: 180}, > {header: "Localita", dataIndex: "localita", > width: 180}, > {header: "Nfasi", dataIndex: "num_fasi", > align: "center"}, > {header: "gap", dataIndex: "max_gap_az", > align: "center"} > ] > }) > //,autoLoad: true //se true anche se il layer non è sulla > mappa viene caricato > }); > > > _______________________________________________ > Users mailing list > Users@geoext.org > http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________ Users mailing list Users@geoext.org http://www.geoext.org/cgi-bin/mailman/listinfo/users