<div dir="ltr">Hello everybody,<div style>am new to GeoEXT and am trying to do the search with form panel.</div><div style>and i want to search features from 2 postgis table, corresponding the field on the formpanel and show them on two separated grid panels, </div>
<div style>when i hit the search button i get nothing on my gridpanel :s</div><div style>here's my java script code: </div><div style><br></div><div style><font color="#0000ff"><br></font></div><div style><div><font color="#0000ff">// define the data source</font></div>
<div><font color="#0000ff"> <span class="" style="white-space:pre">                </span></font></div><div><font color="#0000ff"><span class="" style="white-space:pre">         </span>var protocol= OpenLayers.Protocol.WFS({</font></div>
<div><font color="#0000ff"> url: "<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",</font></div><div><font color="#0000ff"> featureType: "titres_salemed_valid",</font></div>
<div><font color="#0000ff"> featureNS: "<a href="http://geoserver.org/ancfcc">http://geoserver.org/ancfcc</a>"</font></div><div><font color="#0000ff"> });</font></div><div><font color="#0000ff"><br>
</font></div><div><font color="#0000ff"><span class="" style="white-space:pre">                </span>var protocol2= OpenLayers.Protocol.WFS({</font></div><div><font color="#0000ff"> url: "<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",</font></div>
<div><font color="#0000ff"> featureType: "bornes_salemed_valid",</font></div><div><font color="#0000ff"> featureNS: "<a href="http://geoserver.org/ancfcc">http://geoserver.org/ancfcc</a>"</font></div>
<div><font color="#0000ff"> });</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> formPanel = new Ext.form.FormPanel({</font></div>
<div><font color="#0000ff"> title: "Recherche T/R",</font></div><div><font color="#0000ff"> height: 200,</font></div><div><font color="#0000ff"> region: "north",</font></div>
<div><font color="#0000ff"> items: [{</font></div><div><font color="#0000ff"> xtype: "textfield",</font></div><div><font color="#0000ff"> name: "nature__eq",</font></div>
<div><font color="#0000ff"> value: "T",</font></div><div><font color="#0000ff"> fieldLabel: "Nature"</font></div><div><font color="#0000ff"> },{</font></div><div>
<font color="#0000ff"> xtype: "textfield",</font></div><div><font color="#0000ff"> name: "indice__eq",</font></div><div><font color="#0000ff"> value: "20",</font></div>
<div><font color="#0000ff"><span class="" style="white-space:pre">                        </span> fieldLabel: "Indice"</font></div><div><font color="#0000ff"> },{</font></div><div><font color="#0000ff"> xtype: "textfield",</font></div>
<div><font color="#0000ff"> name: "num__eq",</font></div><div><font color="#0000ff"> value: "",</font></div><div><font color="#0000ff"><span class="" style="white-space:pre">                        </span> fieldLabel: "Num:"</font></div>
<div><font color="#0000ff"> },{</font></div><div><font color="#0000ff"> xtype: "textfield",</font></div><div><font color="#0000ff"> name: "complement__eq",</font></div>
<div><font color="#0000ff"> value: "",</font></div><div><font color="#0000ff"><span class="" style="white-space:pre">                        </span> fieldLabel: "Complement:"</font></div><div><font color="#0000ff"> }],</font></div>
<div style><font color="#0000ff"><span class="" style="white-space:pre">        </span> </font></div><div style><span class="" style="white-space:pre"><font color="#0000ff">                // here action on search button </font></span></div>
<div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div><div><font color="#0000ff"><span class="" style="white-space:pre">                </span>buttons: [{text: 'Localiser',</font></div><div><font color="#0000ff"> handler: function(){</font></div>
<div><font color="#ff0000">// here to populate the store 2 with feature from table 2 defined by protocol 2</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> formPanel.getForm().doAction(searchAction2, {</font></div>
<div><font color="#0000ff"> callback: function(response) {</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                                                        </font></span></div><div><font color="#0000ff"> features2 = searchAction2.response.features;</font></div>
<div><font color="#0000ff"><span class="" style="white-space:pre">                </span> <span class="" style="white-space:pre">        </span> <span class="" style="white-space:pre">        </span>store2.loadData(features2);</font></div>
<div><span class="" style="white-space:pre"><font color="#0000ff">                        </font></span></div><div><font color="#0000ff"> };</font></div><div><font color="#0000ff"><span class="" style="white-space:pre">                                                </span> </font></div>
<div><font color="#0000ff"><span class="" style="white-space:pre">                                                </span> };</font></div><div><span class="" style="color:rgb(0,0,255);white-space:pre">        </span><font color="#ff0000">// here to populate the store with feature from table defined by protocol</font><font color="#0000ff"> </font></div>
<div><font color="#0000ff"><span class="" style="white-space:pre">                                                </span> </font></div><div><font color="#0000ff"> formPanel.getForm().doAction(searchAction2, {</font></div><div><font color="#0000ff"><span class="" style="white-space:pre">                        </span> <span class="" style="white-space:pre">                </span>callback: function(response) {</font></div>
<div><span class="" style="white-space:pre"><font color="#0000ff">                                                        </font></span></div><div><font color="#0000ff"> features2 = searchAction2.response.features;</font></div><div>
<font color="#0000ff"><span class="" style="white-space:pre">                </span> <span class="" style="white-space:pre">                </span>store2.loadData(features2);</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                        </font></span></div>
<div><font color="#0000ff"> };</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                        </font></span></div><div><font color="#0000ff"> };</font></div><div><font color="#0000ff"> </font></div>
<div><font color="#0000ff"> }</font></div><div><font color="#0000ff"> }]</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div><div><font color="#0000ff"> });</font></div>
<div><font color="#0000ff"> </font></div><div><font color="#0000ff"> var searchAction = new GeoExt.form.SearchAction(formPanel.getForm(), {</font></div><div><font color="#0000ff"> protocol: protocol,</font></div>
<div><font color="#0000ff"> abortPrevious: true</font></div><div><span style="color:rgb(0,0,255)"> });</span><font color="#0000ff"> </font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> var searchAction2 = new GeoExt.form.SearchAction(formPanel.getForm(), {</font></div>
<div><font color="#0000ff"> protocol: protocol2,</font></div><div><font color="#0000ff"> abortPrevious: true</font></div><div><font color="#0000ff"> });</font></div><div><font color="#0000ff"><br></font></div>
<div><font color="#0000ff"> var cols = [ {name: 'titref', type: 'string'},</font></div><div><font color="#0000ff"> {name: 'mappe', type: 'string'},</font></div><div><font color="#0000ff"> {name: 'type', type: 'string'}</font></div>
<div><font color="#0000ff"> ];</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> var reader = new GeoExt.data.FeatureReader({},cols);</font></div><div><font color="#0000ff"><br>
</font></div><div><font color="#0000ff"> var store = new GeoExt.data.FeatureStore({</font></div><div><font color="#0000ff"> reader: reader,</font></div><div><font color="#0000ff"> fields: cols,</font></div>
<div><font color="#0000ff"> autoLoad: false</font></div><div><font color="#0000ff"> });</font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div>
<div><font color="#0000ff"><span class="" style="white-space:pre">                </span>// pour les titres </font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div><div><font color="#0000ff"><span class="" style="white-space:pre">                </span>var cols2 = [ {name: 'name', type: 'string'},</font></div>
<div><font color="#0000ff"> {name: 'x', type: 'string'},</font></div><div><font color="#0000ff"> {name: 'y', type: 'string'}</font></div><div><font color="#0000ff"> ];</font></div>
<div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> var reader2 = new GeoExt.data.FeatureReader({},cols2);</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> var store2 = new GeoExt.data.FeatureStore({</font></div>
<div><font color="#0000ff"> reader: reader2,</font></div><div><font color="#0000ff"> fields: cols2,</font></div><div><font color="#0000ff"> autoLoad: false</font></div><div><font color="#0000ff"> });</font></div>
<div><font color="#0000ff"><div>// create grid panel configured with feature store</div><div> gridPanel = new Ext.grid.GridPanel({</div><div> title: "results",</div><div> region: "center",</div>
<div> store: store2,</div><div> height: 100,</div><div> columns: [{</div><div> header: "titref",</div><div> width: 200,</div><div> sortable: true,</div>
<div> dataIndex: "titref"</div><div> }, {</div><div> header: "mappe",</div><div> width: 60,</div><div> sortable: true,</div><div> dataIndex: "mappe"</div>
<div> }, {</div><div> header: "type",</div><div> width: 60,</div><div> align: 'right',</div><div> sortable: true,</div><div> dataIndex: "type"</div>
<div> }],</div><div> sm: select</div><div> });</div><div><span class="" style="white-space:pre">                </span></div><div><span class="" style="white-space:pre">                </span>// create grid panel configured with feature store for bornes layer</div>
<div> gridPanel2 = new Ext.grid.GridPanel({</div><div> title: "tableau des bornes",</div><div> region: "south",</div><div> store: store2,</div><div> height: 250,</div>
<div> columns: [{</div><div> header: "name",</div><div> width: 100,</div><div> sortable: true,</div><div> dataIndex: "name"</div><div>
}, {</div><div> header: "x",</div><div> width: 120,</div><div> sortable: true,</div><div> dataIndex: "x"</div><div> }, {</div>
<div> header: "y",</div><div> width: 120,</div><div> align: 'right',</div><div> sortable: true,</div><div> dataIndex: "y"</div>
<div> }],</div><div> sm: select2</div><div> });</div><div><span class="" style="white-space:pre">                </span></div></font></div><div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div>
<div><span class="" style="white-space:pre"><font color="#0000ff">                </font></span></div></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div><div><br></div>-- <br><div dir="ltr">*Asma OUQALLI*<br>
<br>Élève ingénieur : 3ème Sciences d'Information Géographique (SIG).<br>Chef de commission développement professionnel - Rotaract EHTP. <br>Chef de cellule Media - Olympiades EHTP 2012.<br> Ecole Hassania des Travaux Publics.<br>
Mobile : +212 672 48 23 15.<br> Email : <a href="mailto:asma.ouqalli@gmail.com" target="_blank">asma.ouqalli@gmail.com</a><br><br></div>
</div></div>