Dec 14, 2012, 11:21 PM
MultiCombo: Set Multiple Selected Values in Code Behind
Problem: I select a row in a Grid that should populate a form. I am loading the MultiCombo from a store (That is working fine). I cannot preselect multiple items. LoadFundingSources() below loads the items into the MultiCombo Box. strFunding below in the RowSelection event below is a comma delimited string of numeric values.
ASPX:
ASPX:
<ext:MultiCombo ID="mcbFundingSource" runat="server" FieldLabel="Funding Source" Name="FundingSourceID"
DisplayField="FundingSource"
ValueField="FundingSource"
EmptyText="Select Funding Source..."
Selectable="true"
QueryMode="Local"
ForceSelection="true"
TriggerAction="All"
SelectOnFocus="true"
AllowBlank="true">
<Store>
<ext:Store ID="StoreFundingSources" runat="server">
<Model>
<ext:Model ID="Model17" runat="server">
<Fields>
<ext:ModelField Name="FundingSource" />
<ext:ModelField Name="FundingSourceID" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiCombo>
Code Behind:private void LoadFundingSources()
{
EarlyChildhoodCouncilData.FundingSource objItems = new EarlyChildhoodCouncilData.FundingSource();
DataView dv = objItems.GetList().DefaultView;
dv.RowFilter = "Active='" + true + "'";
dv.Sort = "SortOrder";
StoreFundingSources.DataSource = dv;
StoreFundingSources.DataBind();
}
public void RowSelectCase(object sender, Ext.Net.DirectEventArgs e)
{
string caseID = e.ExtraParams["CaseID"];
EarlyChildhoodCouncilData.Case objCase = new EarlyChildhoodCouncilData.Case(int.Parse(caseID));
LoadFundingSources();
this.FormPanel1.SetValues(new
{
objCase.CaseID,
objCase.ReferralSourceID
});
mcbFundingSource.SetValue(1); //This only selects one value
String[] strFunding = objCase.FundingSource.Split(',');
for (Int32 x = 0; x < strFunding.Length; x++)
{
mcbFundingSource.SetValue(strFunding[x]); //This only loads the last item
}
}
Last edited by Baidaly; Dec 15, 2012 at 1:00 AM.
Reason: Please, use [CODE] tag