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

RadGrid GridDropDownColumn client side

3 Answers 338 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas Dietz
Top achievements
Rank 1
Thomas Dietz asked on 14 Feb 2011, 10:51 AM
Hi all,
 I'm using RadGrid in Edit mode, with some GridDropDownColumns with the default GridDropDownListColumnEditor. I can even setup the client side event handler for the SelectedIndexChanged event. There I use a javascript alert() to see the contents of the combo.

The challenge is now to transfer this value to another Combobox a) in the same row or b) in another row.

How can i set the Combobox from the client side javascript?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Feb 2011, 10:20 AM
Hello Thomas,

The following code snippet shows how to get the selected value in 'OnClientSelectedIndexChanged' event.

ASPX:
<telerik:GridDropDownColumn DataField="FirstName" HeaderText="Schedule Type" UniqueName="cavtScheduleType"
                       DropDownControlType="RadComboBox" ListTextField="FirstName" ListValueField="FirstName" DataSourceID="SqlDataSource1">
                   </telerik:GridDropDownColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
       {
 
           GridEditFormItem edititemForCombo = (GridEditFormItem)e.Item;
           GridEditManager editMan = edititemForCombo.EditManager;
           GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("cavtScheduleType"));
           RadComboBox radComboScheduleType = editor.ComboBoxControl;
           radComboScheduleType.OnClientSelectedIndexChanged = "SelectedIndexChanged";
       }
   }

Java Script:
<script type="text/javascript">
      function SelectedIndexChanged(sender, args) {
        args.get_item().get_value();//getting selected value
        debugger;
    }
</script>

 And if you want to get the any other control(which is in edit/insert form)  from client side, please try the approach mentioned in the following code library.
Retrieving grid editor value client side

Thanks,
Princy.
0
Thomas Dietz
Top achievements
Rank 1
answered on 15 Feb 2011, 10:39 AM
Hi Princy,

thank you for the answer, I already succeeded to read the values from the combo box on the client side.

However, the question for me is how can i set the combo box from client code?

Is there something like args.get_item().set_value(<value>);
0
Princy
Top achievements
Rank 2
answered on 16 Feb 2011, 09:22 AM
Hello Thomas,

If you want to set the selected value of one combobox to another combobox in 'SelectedIndexChanged' event , try the following approach.

Java Script:
<script type="text/javascript">
      function SelectedIndexChanged(sender, args) {
        var value= args.get_item().get_value(); //getting selected value
        var combo = $find("<%=RadComboBox2.ClientID %>");//accessing another combobox
        combo.set_text(value);//setting value
      }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Thomas Dietz
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Thomas Dietz
Top achievements
Rank 1
Share this question
or