Sep 09, 2016, 8:17 AM
[CLOSED] Set SelectedItem.Value in codebehind, get value in DocumentReady
Hi
Im migrating some code från 1.x to 3.2. And I ran into some problems.
I have a combobox that I load up in PageLoad(), and I also set the SelectedItem of it in PageLoad().
Then I have a function running in DocumentReady, that I want to pick up the value set in PageLoad() to hide/show a button.
This I cant get to work in ver. 3.2
Please see test example
Mikael Jürke
Im migrating some code från 1.x to 3.2. And I ran into some problems.
I have a combobox that I load up in PageLoad(), and I also set the SelectedItem of it in PageLoad().
Then I have a function running in DocumentReady, that I want to pick up the value set in PageLoad() to hide/show a button.
This I cant get to work in ver. 3.2
Please see test example
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
List<Combo> list = new List<Combo>();
list.Add(new Combo { ID = "0", Name = "Hide" });
list.Add(new Combo { ID = "1", Name = "Show" });
storePrio.DataSource = list;
storePrio.DataBind();
cbPrio.SelectedItem.Value = "0";
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<script type="text/javascript">
function PrioChange() {
try {
var prioValue = App.cbPrio.getValue();
if (prioValue == "0") {
Ext.get(btnOk).hide();
}
else {
Ext.get(btnOk).show();
}
}
catch (e) {
Ext.Msg.alert('Error', e.message);
}
}
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server">
<Listeners>
<DocumentReady Handler="PrioChange();" />
</Listeners>
</ext:ResourceManager>
<ext:Store ID="storePrio" runat="server">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:Panel runat="server" Title="Panel">
<Items>
<ext:ComboBox FieldLabel="Prio" ID="cbPrio" Width="200" runat="server" Editable="false" Mode="Local"
TriggerAction="All"
StoreID="storePrio"
DisplayField="Name"
ValueField="ID">
<Listeners>
<Select Handler="PrioChange();" />
</Listeners>
</ext:ComboBox>
</Items>
<Buttons>
<ext:Button runat="server" ID="Button1" Text="Cancel" Icon="Cancel">
<DirectEvents>
</DirectEvents>
</ext:Button>
<ext:Button runat="server" ID="btnOk" Text="Ok" Icon="Accept">
<DirectEvents>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:Panel>
</form>
</body>
</html>
Best regardsMikael Jürke
Last edited by fabricio.murta; Sep 12, 2016 at 11:03 PM.