<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Riccardo,<br>
<br>
here a code snippet I have in use:<br>
<br>
<tt>myStore.setDefaultSort('magnitudo', 'DESC'); // just after
instanciating the store</tt><br>
<br>
Best regards,<br>
Chris<br>
<div class="moz-signature">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<style type="text/css">
#signature {
color: #333 !important;
font-family: monospace;
                        font-size: 12px;
padding: 10px;
line-height: 1.5em;
}
#highlight-container {
padding: 5px;
width: 450px;
margin: 30px 0;
border-width: 0px 0 0px 0;
border-right-width: 0;
border-left-width: 0;
border-style: dotted;
border-color: #333;
}
#signature a,
#signature a:link,
#signature a:visited,
#signature a:hover,
#signature a:active {
color: darkblue !important;
}
#signature address {
font-style: normal;
}
#col-container {
width: 550px;
}
#col-1 {
width: 180px; float: left;
}
#col-2 {
width: 320px; float: left;
}
#col-clear {
clear: both; padding-top: 30px;
}
#signature img {
margin-top:10px;
}
#col-container p,
#col-container address {
margin: 4px 0 0 0;
}
#signature .no-margin {
margin: 0;
}
#highlight {
font-weight: bold;
}
</style>
<div id="signature">
<div id="col-container"><br>
</div>
</div>
</div>
<br>
Am 02.11.2011 12:16, schrieb Riccardo Gaeta:
<blockquote
cite="mid:CAHQmNyFeriZKcZQ=8=g39Ec7HM0vZZDF+2-xa8wCrB8XeAv=4g@mail.gmail.com"
type="cite">Hi all,
<div>I have a problem: I'm not able to set correctly the sortInfo
to have my data ordered in my GridPanel by a column.</div>
<div>I've spent lot of time by forum but I was not able to find a
solution for me.</div>
<div>I load a WFS layer from MapServer/Postgis, then I like order
the data (like 20-30 records) by date field.</div>
<div>My date field originally come from Postgres "timestamp", but
here I translate it as string.</div>
<div>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).</div>
<div><br>
</div>
<div>I use Ext 3.4.0, and I try my page on Chrome.</div>
<div><br>
</div>
<div>Thanks everyone could give me a suggest!!!</div>
<div><br>
</div>
<div>The code (the commented line are my test:they don't work):</div>
<div><br>
</div>
<div>
<div>var sismi = new OpenLayers.Layer.Vector("Sismicità
strumentale - ultimi 15 giorni", {</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>styleMap:
styleMap_sismi,</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>strategies:
[new OpenLayers.Strategy.Fixed()],</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>protocol:
new OpenLayers.Protocol.WFS({</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>url:
urlMS_sismi, version: "1.1.0", featureType: "sism_last15",</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>featureNS:
"<a moz-do-not-send="true"
href="http://mapserver.gis.umn.edu/mapserver">http://mapserver.gis.umn.edu/mapserver</a>",</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>extractAttributes:
true, extractStyles: true, geometry: "msGeometry", srsName:
"EPSG:32632"</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>})</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>});</div>
<div>var store_sismi = new GeoExt.data.FeatureStore({</div>
<div> fields: [</div>
<div> {name: "latitudine", type: "float"},</div>
<div> {name: "longitudine", type: "float"},</div>
<div> {name: "profondita", type: "float"},</div>
<div> {name: "magnitudo", type: "float",
mapping:"magnitudo"},</div>
<div> {name: "regione_geografica", type: "string"},</div>
<div> {name: "num_fasi", type: "integer"},</div>
<div> {name: "max_gap_az", type: "integer"},</div>
<div> {name: "localita", type: "string"},</div>
<div> {name: "full_date", type: "string"}</div>
<div> ],</div>
<div> layer: sismi</div>
<div> //, remoteSort: false //to enable sorting from
server</div>
<div> , sortInfo:{"field": 'magnitudo', "direction":
"DESC"} //don't work...</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>//,
paramOrder:['magnitudo'] </div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>});</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>//store_sismi.setDefaultSort('magnitudo',
'DESC');</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>//store_sismi.sort('magnitudo',
"DESC");</div>
</div>
<div><br>
</div>
<div>
<div>gridPanel = new Ext.grid.GridPanel({</div>
<div> xtype : 'grid', //a cosa serve?</div>
<div> title: "Elenco degli eventi sismici",</div>
<div> region: "south",</div>
<div> //stripeRows: true,</div>
<div> columnLines: true,</div>
<div> viewConfig: {forceFit: true},</div>
<div> store: store_sismi,</div>
<div> loadMask: true, //a cosa serve?</div>
<div> height: Math.round(height_map*0.4), //280</div>
<div> autoScroll: true,</div>
<div> collapsible: true,</div>
<div> collapsed: false,</div>
<div> //sm: new
GeoExt.grid.FeatureSelectionModel(), //per sincronizzare grid
e features</div>
<div> cm: new Ext.grid.ColumnModel({</div>
<div> defaults: {</div>
<div> sortable: true</div>
<div> },</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>columns:
[<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div> {header: "<b>Magnitudo
[ML]</b>", dataIndex: "magnitudo", decimalPrecision: 2,</div>
<div> align: "center", width: 150},</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>{header:
"<b>Tempo origine</b>", dataIndex: "full_date",
width: 175},</div>
<div> {header: "Prof. [km]", dataIndex:
"profondita", decimalPrecision: 2, align: "center"},</div>
<div> {header: "Lat", dataIndex:
"latitudine", decimalPrecision: 3, align: "center"},</div>
<div> {header: "Lon", dataIndex:
"longitudine", decimalPrecision: 3, align: "center"},</div>
<div> {header: "Regione geografica",
dataIndex: "regione_geografica", width: 180},</div>
<div> {header: "Localita", dataIndex:
"localita", width: 180},</div>
<div> {header: "Nfasi", dataIndex:
"num_fasi", align: "center"},</div>
<div> {header: "gap", dataIndex:
"max_gap_az", align: "center"}</div>
<div> ]</div>
<div> })</div>
<div> //,autoLoad: true //se true anche se il layer non è
sulla mappa viene caricato</div>
<div> });</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@geoext.org">Users@geoext.org</a>
<a class="moz-txt-link-freetext" href="http://www.geoext.org/cgi-bin/mailman/listinfo/users">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
</body>
</html>