martedì 9 giugno 2015

How to get the value of selected displayField in Ext.Net Combobox - Javascript

Nel caso che vogliamo ottenere il testo dell'elemento selezionato del controllo Combobox di Ext.Net, utilizzando il metodo getAt ed il metodo get, passando l'indice nel prima cosa ed il nome del campo  DisplayField.

Qui di seguito un esempio di codice da utilizzare lato script.

  var GetTesto = function (value) {
            if (value == null || value == " " || value == "") {
                return " ";
            }
            var Indice = StoreCmbDati.find("NOMECAMPOVALUEFIELD", value);
            var testo = StoreCmbDati.getAt(Indice).get("NOMECAMPODISPLAYFIELD");
 };

 ext:Column ColumnID="NOMECOLONNA" Header="NOMECOLONNA" Width="80" DataIndex="NOMECOLONNA">
                                      Renderer Fn="GetTesto" /
Editor
ext:ComboBox ID="CmbDati" ValueField="NOMECAMPOVALUEFIELD" DisplayField="NOMECAMPODISPLAYFIELD" Shadow="Drop"
                                                                                        Mode="Local" TriggerAction="All" ForceSelection="true" runat="server"
                                                                                        Store
                                                                                            ext:Store ID="StoreCmbDATI" runat="server"
                                                                                                Reader
                                                                                                    ext:JsonReader IDProperty="ID"
                                                                                                        Fields
                                                                                                            ext:RecordField Name="NOMECAMPOVALUEFIELD" Mapping="NOMECAMPOVALUEFIELD" /
                                                                                                                                                                                                                    /Fields
                                                                                                    /ext:JsonReader
                                                                                                /Reader
                                                                                            /ext:Store
                                                                                        /Store
                                                                                    /ext:ComboBox

Nessun commento: