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

Set value to cell in DetailTables in Radgrid using javascript

3 Answers 463 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vinayak
Top achievements
Rank 1
vinayak asked on 23 Feb 2009, 09:40 AM

Hi,
I am using radgrid to list all the records. I am using nested tables i.e. telerik:GridTableView. There is one  RadComboBox in first column of DetailTables(Nested table under mastertable). I want to set some value in second column of same row which is depend upon selecteditem of RadComboBox.

I can call the javascript function on selectedindexchanged event of RadComboBox. But I am not getting the cell of the radgrid in the same row of the RadComboBox of which client side event is occured.
 
I am not able to get cell of the DetailTables under radgrid. How can I set the value in to that cell which is in the same row as that of RadComboBox?

Thanks,
Vinayak Chavan.

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 25 Feb 2009, 01:07 PM
Hi vinayak,

Once you get the value of the combo, you can use this method to get a reference to the cell which contains the related vale. However, please keep in mind that this change will not be persistted on postback.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
vinayak
Top achievements
Rank 1
answered on 25 Feb 2009, 02:08 PM
Hi Yavor ,

Thanks for your reply. Actully I am using radcombobox inside detailtable of radgrid. I am calling javascript function on selectedindexchanged of this radcombobox. So there is no actual radgrid event.

I am able to access the object of radgrid and detailtable under it in javscript function which I am calling on selectedindexchanged of radcombo. But I am not getting the selected row (It should be current row in which radcombo client side event is fired) .
Is it because  event is for radcombo and not for radgrid?  

Appreciate if you could help me in it!

Thanks,
Vinayak Chavan
0
Princy
Top achievements
Rank 2
answered on 26 Feb 2009, 08:08 AM
Hello Vinayak,

You can try out the following code select the detail table row on the selection change of the combo inside the ItemTemplate of a GridTemplateColumn of the detail table.
aspx:
<telerik:RadGrid runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid2_ItemDataBound" > 
    <MasterTableView Name="Master"
      <DetailTables> 
       <telerik:GridTableView DataSourceID="SqlDataSource2" Name="Detail" runat="server" > 
        <Columns> 
         <telerik:GridTemplateColumn UniqueName="DropDown"
            <ItemTemplate> 
                <asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource1" DataTextField="Order" runat="server"
                </asp:DropDownList> 
           </ItemTemplate> 
            </telerik:GridTemplateColumn> 
               ....

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail") 
        { 
            GridDataItem item1 = (GridDataItem)e.Item; 
            DropDownList combo = (DropDownList)item1.FindControl("DropDownList1"); 
            combo.Attributes.Add("onChange", "return Change('" + item1.ItemIndex + "');"); 
        }  
    } 

js:
function Change(indx) 
  //code to select the row  

-Princy.
Tags
Grid
Asked by
vinayak
Top achievements
Rank 1
Answers by
Yavor
Telerik team
vinayak
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or