Oct 23, 2018, 7:48 PM
[CLOSED] dynamically binding a control's store to new dataset
Hi Ext.net,
Having trouble getting my multiselect combo to reflect any new data dynamically bound to a control (e.g. multicombo).
I've abstracted the issue out to this simple example below and included some inline comments that specify the problems.
Any ideas on what I'm missing? This should be trivial, so must be something obvious. Thanks.
Having trouble getting my multiselect combo to reflect any new data dynamically bound to a control (e.g. multicombo).
I've abstracted the issue out to this simple example below and included some inline comments that specify the problems.
Any ideas on what I'm missing? This should be trivial, so must be something obvious. Thanks.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>MultiCombo - Ext.NET Examples</title>
<script runat="server">
private object TestData1
{
get
{
return new object[]
{
new object[] { "1A", "AVal1" },
new object[] { "1B", "AVal2" },
new object[] { "1C", "AVal3" },
new object[] { "1D", "AVal4" },
new object[] { "1E", "AVal5" },
new object[] { "1F", "AVal6" }
};
}
}
private object TestData2
{
get
{
return new object[]
{
new object[] { "2A", "BVal1" },
new object[] { "2B", "BVal2" },
new object[] { "2C", "BVal3" },
new object[] { "2D", "BVal4" },
new object[] { "2E", "BVal5" },
new object[] { "2F", "BVal6" }
};
}
}
protected override void OnLoad(EventArgs e)
{
this.TestCombo.GetStore().DataSource = TestData1;
this.TestCombo.GetStore().DataBind();
//during OnLoad of Page's lifecycle, am able to get the comboboxes to reflect whatever dataset I bind against its store's datasource
this.explicitStore.DataSource = TestData1;
this.explicitStore.DataBind();
}
//should work b/c any call backs to non-static serverside methods should cause the Page lifecycle to execute and allow access to all page's web controls
[DirectMethod]
public void DM_RefreshMultiCombo()
{
this.TestCombo.GetStore().DataSource = TestData2;
this.TestCombo.GetStore().DataBind();
this.explicitStore.DataSource = TestData2;
this.explicitStore.DataBind();
//unfortunately DirectMethod unable to get the multi combos to reflect 2nd dataset
}
//should also work b/c any call backs to non-static serverside methods should cause the Page lifecycle to execute and allow access to all page's web controls
protected void DE_RefreshMultiCombo(object sender, DirectEventArgs e)
{
this.TestCombo.GetStore().DataSource = TestData2;
this.TestCombo.GetStore().DataBind();
this.explicitStore.DataSource = TestData2;
this.explicitStore.DataBind();
//DirectEvent handler also unable to get the multi combos to reflect 2nd dataset
}
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:MultiCombo runat="server" ID="TestCombo" SelectionMode="Selection" DisplayField="name" ValueField="abbr">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="abbr" />
<ext:ModelField Name="name" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:MultiCombo>
<br />
<ext:MultiCombo runat="server" ID="ExplicitStoreCombo" SelectionMode="Selection" DisplayField="name" ValueField="abbr">
<Store>
<ext:Store ID="explicitStore" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="abbr" />
<ext:ModelField Name="name" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:MultiCombo>
<br />
<ext:Button
ID="Button1"
runat="server"
Text="Load MultiCombo w/ DirectMethod"
>
<Listeners>
<Click Handler="App.direct.DM_RefreshMultiCombo();" />
</Listeners>
</ext:Button>
<ext:Button
ID="Button2"
runat="server"
Text="Load MultiCombo w/ DirectEvent"
>
<DirectEvents>
<Click OnEvent="DE_RefreshMultiCombo" />
</DirectEvents>
</ext:Button>
</form>
</body>
</html>
Last edited by fabricio.murta; Oct 25, 2018 at 8:39 PM.