PDA

View Full Version : [CLOSED] MultiCombo not selecting items in code behind



Sowjanya
Oct 14, 2013, 3:32 PM
hi,

I am using multicombo in my application. I am trying to select some of those items from code behind, but it does not select them ( selecting menaing...want those items to be checkmarked and highlighted.) can you pls resolve this issue ?
I am binding data to it on page load.

here is the code:
-----------------------


<ext:MultiCombo ID="ddlRepPrograms" runat="server" FieldLabel ="Reporting Programs"
Width="500" ValueField="REP_PROGRAM_ID" DisplayField="REP_PROGRAM_NAME" Margins="0 0 10 0">

<Store>


<ext:Store ID="StoreRepPrograms" runat="server" AutoLoad="true">
<Proxy>
<ext:AjaxProxy Json="true" Url='<%#RepProgramsUrl%>' AutoDataBind="true" >
<ActionMethods Read="POST" Create="POST"/>
<Headers>

<ext:Parameter Name="Accept" Value="application/json" />
<ext:Parameter Name="Content-Type" Value="application/json" />


</Headers>
<Reader>
<ext:JsonReader Root=""/>
</Reader>
<Writer>
<ext:JsonWriter Root="" Encode="true"/>
</Writer>


</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model5" runat="server">
<Fields>
<ext:ModelField Name="REP_PROGRAM_ID" Type="Int"/>
<ext:ModelField Name="REP_PROGRAM_NAME" Type="String"/>

</Fields>
</ext:Model>
</Model>

</ext:Store>


</Store>

</ext:MultiCombo>

Here is the code where I am trying to highlight some of the items in multiselect combo from code behind, on a grid row select event.:
---------------------------------------------------------------------------------------------------------------------------------------------------------





protected void ProjectSelect(object sender, DirectEventArgs e) // use this for populatg prj form if prj grid row is selected.
{
.
.
.
.

Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(response);


if (grid1Data.Count() > 0)
{
Ext.Net.ListItem lt = new Ext.Net.ListItem();
foreach (var record in grid1Data)
{
repProgramID = (record["PROGRAM_ID"]);
object RepPgmID = Convert.ToInt32(repProgramID);

this.ddlRepPrograms.SelectedItems.Add(new Ext.Net.ListItem(record["PROGRAM_NAME"]));



}

}

else
{
this.ddlRepPrograms.Select("No Program");

}
.
.
.
.



The attached screenshot shows 4 options in multicombo:

No Program, Test 1, test 2, zzzzzzz

I want test 1 and test 2 selected in multicombo, on grid row select event in Museum Projects grid.

when i try the above, still it shows the multicombo unselected with those items.., as it was on page load.


pls help me resole this asap.

Thanks,
Veda

Daniil
Oct 14, 2013, 5:09 PM
Hi Veda,

Please try to call:

this.ddlRepPrograms.UpdateSelectedItems();
after modifying the SelectedItems collection.

Sowjanya
Oct 14, 2013, 5:13 PM
Hi Veda,

Please try to call:

this.ddlRepPrograms.UpdateSelectedItems();
after modifying the SelectedItems collection.

sorry, that did not work, either !

Baidaly
Oct 14, 2013, 11:38 PM
Hello!

I tried the code below and it works fine. Can you provide your sample to reproduce?


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if(!X.IsAjaxRequest)
{
Store1.DataSource = new object[]
{
new { REP_PROGRAM_ID = 1, REP_PROGRAM_NAME = "Program 1"},
new { REP_PROGRAM_ID = 2, REP_PROGRAM_NAME = "Program 2"},
new { REP_PROGRAM_ID = 3, REP_PROGRAM_NAME = "Program 3"}
};
Store1.DataBind();
}
}

protected void ProjectSelect(object sender, DirectEventArgs e)
{
this.ddlRepPrograms.SelectedItems.Add(new Ext.Net.ListItem(1));
this.ddlRepPrograms.UpdateSelectedItems();
}
</script>

<!DOCTYPE>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server" />

<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="REP_PROGRAM_ID" Type="Int" />
<ext:ModelField Name="REP_PROGRAM_NAME" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:MultiCombo ID="ddlRepPrograms" runat="server" Width="260" StoreID="Store1" ValueField="REP_PROGRAM_ID" DisplayField="REP_PROGRAM_NAME">

</ext:MultiCombo>

<ext:Button runat="server" Text="Click Me">
<DirectEvents>
<Click OnEvent="ProjectSelect"></Click>
</DirectEvents>
</ext:Button>
</div>
</form>
</body>
</html>