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

[Solved] Access RadComboBox in GridTemplateColumn

3 Answers 276 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josef
Top achievements
Rank 1
Josef asked on 11 Apr 2008, 06:39 AM
Hello!

I have a RadGrid with two GridTemplateColumns. Each Column has a RadComboBox in the EditItemTemplate.
The Comboboxes have the Property "EnableLoadOnDemand" set to true and i use the "ItemsRequested" Event to populate them.

Now (if i am in InsertMode) i would like to read out the "SelectedValue" of the first Combobox in the "ItemsRequested" Event of the second (should be filled in order to whats selected in the first).

I am trying to access the "SelectedValue" with the following code:
############
(RadGrid1.MasterTableView.GetInsertItem().FindControl("cmbGrouping") as RadComboBox).SelectedValue;
############

The problem is that in the "ItemsRequested" Event of the second ComboBox this code returns an empty string but in the "RadGrid1_InsertCommand" Event it returns the correct ID.

Can anyone tell my what iam doing wrong or how to access the values of controls in different GridTemplateColumns??

thx in advance
Josef

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 14 Apr 2008, 01:12 PM
Hi Josef,

This is indeed expected.The ItemsRequested event of the combobox is meant to update only the combobox itself, not other controls. Therefore, if you try to access any property of the first combobox in the ItemsRequested event of the second combobox, this property will be null/empty.

I would rather suggest that you use client-side approach. You can get the selected value of the first combobox at the client-side and pass it to the second's combobox context object in the OnClientItemsRequesting event, like:


function itemsRequesting(sender, eventArgs)
{
var context = eventArgs.get_context();
context["SelectedValue"] = combo1.get_selectedValue();
}

Then, in the Itemsrequested server event of the second combobox you can simlpy get the context object using the event arguments:
protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
   //e.Context
   ...
}

Hope this helps.

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 14 Apr 2008, 03:18 PM
Thx for your answer!

My problem is that i do not manage to access the RadComboBox inside the EditItemTemplate within the GridTemplateColumn of the edited row.

I am looking for something like:
#####################
radgrid.get_mastertableview.get_editedItems[0].findcontrol("cmbName")
#####################


thx in advance
Markus
0
Vlad
Telerik team
answered on 15 Apr 2008, 02:50 PM
Hi Markus,

You can achieve this if you expose the ClientID for desired combo as JavaScript variable and pass this to $find() method.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Josef
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Markus
Top achievements
Rank 2
Vlad
Telerik team
Share this question
or