This is a migrated thread and some comments may be shown as answers.

Parent/Child ComboBoxs in new (Q2 2013) Batch editing.

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vijay
Top achievements
Rank 1
vijay asked on 25 Jun 2013, 09:16 PM
I am trying to implement new Batch Edit functionality of RadGrid. I have a Radgrid with 2 columns both the columns are TemplateColumns with RadComboBox in EditTemplate. I want to load data in a ComboBox (LoadOnDemand) in column b in the same row based on the Selected value of the Combobox in column a. 

I did try to use onClientItemsRequsting to capture the selected value and saved it to the context object so that i can use it in ItemRequested event's filter property on the code behind. It works fine for the first time.

The issue is once the combobox is loaded it never hits ItemRequested again. So even if we change the selected value of the 1st combobox, the 2nd combobox values remains the same as it already has values and will not hit itemrequested on subsequent selections.

Can anyone help me with this scenario.

 

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 28 Jun 2013, 08:15 AM
Hello,

I have assembled a sample project showing the desired functionality implemented. The idea is to manually call requestItems on the second RadComboBox and then populate the second RadComboBoxin the ItemRequested event as shown below.
<telerik:RadComboBox ID="RadComboBox1" runat="server"OnPreRender="RadComboBox1_PreRender"
    OnClientSelectedIndexChanged="SelectedIndexChanged">
</telerik:RadComboBox>
function SelectedIndexChanged(sender, args)
{
    var comboBox = $telerik.findControl($find("<%= RadGrid1.ClientID %>").get_element(), "RadComboBox2");
    comboBox.requestItems(args.get_item().get_value());
}
protected void RadComboBox2_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("Continent");
    table.Columns.Add("Country");
    table.Rows.Add("Europe""Germany");
    table.Rows.Add("Europe""France");
    table.Rows.Add("Africa""Egypt");
 
    RadComboBox combo = sender as RadComboBox;
    combo.DataSource = table.Select("Continent = '" +  e.Text +"'").CopyToDataTable();
    combo.DataTextField = "Country";
    combo.DataValueField = "Country";
    combo.DataBind();
}

Regards,
Antonio Stoilkov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
vijay
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or