[Users] Problem sorting data in a GridPanel by a column
Hugo
hfpmartins at gmail.com
Fri Nov 4 14:25:41 CET 2011
Hi Riccardo,
you can try to sort your data using a the load listener on your store.
Something like the following:
store_sismi.on('load', function(store){
store.sort('magnitudo', 'DESC');
});
Hope that helps.
Cheers,
Hugo
On Fri, Nov 4, 2011 at 1:04 PM, Riccardo Gaeta <riccardog79 at gmail.com>wrote:
> Thanks Christain, I've tried your tip but it doesn't work for me.
> I don't know why but GeoExt persist to put my data in ascendent order by
> the "date" column, without ANY specification about that...I don't really
> understand.
>
> Any other ideas???
>
> Thanks to all
>
>
> 2011/11/4 Christian Mayer <mayer at terrestris.de>
>
>> **
>> 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 listUsers at geoext.orghttp://www.geoext.org/cgi-bin/mailman/listinfo/users
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at geoext.org
>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
--
Hugo Martins
LabNT - ISEGI UNL
Campus de Campolide
1070-312 Lisboa
N 38°43'56.84", W 9°9'35.74"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111104/0c8b47d7/attachment-0001.htm
More information about the Users
mailing list