PDA

View Full Version : [CLOSED] Ext Combobox - Selected value changed from code behind on postback event is not reflected on the UI



Maitreya
Nov 03, 2014, 12:40 PM
I have an Ext.Net combobox. I am using version 2 of Ext.Net and v4.0 of .Net

On a particular event, I am setting its value from javascript.



Ext.getCmp('ddlCountryOfRisk_ddl').store.clearFilt er();
Ext.getCmp('ddlCountryOfRisk_ddl').store.load();
Ext.getCmp('ddlCountryOfRisk_ddl').clearValue();
Ext.getCmp('ddlCountryOfRisk_ddl').setValue(cntry) ;
Ext.getCmp('ddlCountryOfRisk_ddl').readOnly = true;



Now if I am trying to change the selected value from the code behind on a postback event, this changed value is not showing back on the UI.



ddlCountryOfRisk.ReadOnly = false;
ddlCountryOfRisk.SelectedValue = value;



The same issue occurs if I change the value from UI and then try to set it from code behind on post back event.


Please assist me.

Daniil
Nov 03, 2014, 4:05 PM
Hi @Maitreya,

Please provide a full test case to reproduce the issue.

Maitreya
Nov 04, 2014, 5:10 AM
I have a form which contains a combobox and a gridpanel into it.

RowEditing direct event of the GridPanel, I am calling a method which sets the selected value for the combobox.




<Plugins>
<ext:RowEditing ID="reOwner" runat="server" ClicksToEdit="2" CommitChangesText="You need to cancel or commit your changes" SaveHandler="ValidateAddParent">
<Listeners>
<BeforeEdit Fn="EnableOwnershipEditors" />
<CancelEdit Fn="EditOwnershipCancelled" />
</Listeners>
<DirectEvents>
<Edit OnEvent="RecordEdited" Before="insertOwner = false;" After="EnableAddButton(#{reOwner});SetUltimateParent();">
<ExtraParams>
<ext:Parameter Name="Values" Value="Ext.encode(GetModifiedValues(#{pnlOwnership}))"
Mode="Raw" />
</ExtraParams>
<EventMask ShowMask="true" CustomTarget="#{pnlOwnership}" />
</Edit>
</DirectEvents>
</ext:RowEditing>
</Plugins>




Code Behind:




protected void RecordEdited(object sender, DirectEventArgs e)
{
var json = e.ExtraParams["Values"];

....


ddlCountryOfRisk.SelectedItem.Value = value
...

}
}



This selected value set on the direct event is not reflected on the UI.

Vladimir
Nov 04, 2014, 10:26 AM
Hi

If you need to change selected value in combo during direct event then use the following code


this.ComboBox2.SelectedItems.Clear();
this.ComboBox2.SelectedItems.Add(new Ext.Net.ListItem { Value = "0" });
this.ComboBox2.UpdateSelectedItems();

It is demonstrated in the following online example
http://examples2.ext.net/#/Form/ComboBox/Items_Actions/