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

[Solved] How to get DataKeyValue from RadCombox's onchange inside of RadGrid?

2 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Enoch Kuang
Top achievements
Rank 1
Enoch Kuang asked on 01 Feb 2010, 08:47 PM

Hi,

I have a RadCombox inside of a RadGrid and from OnClientSelectedIndexChanged event I need to call javascript function to get GridDataItem's DataKeyValue. Is there any example somewhere?

Thanks,
Enoch

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Feb 2010, 06:32 AM
Hello Enoch,

Here's an example to access the datakeyvalue of a row when a selection change happens in the combobox nested in the RadGrid:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server"
   <MasterTableView ClientDataKeyNames="ProductID" DataSourceID="SqlDataSource1"
       <Columns> 
          <telerik:GridTemplateColumn> 
              <ItemTemplate> 
                  <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ProductName" OnClientSelectedIndexChanged="ClientSelectedIndexChanged" >                     
                  </telerik:RadComboBox> 
              </ItemTemplate> 
          </telerik:GridTemplateColumn> 
          .... 

js:
function ClientSelectedIndexChanged(sender,args)   
    {   
        var rowElement = sender._element.parentNode.parentNode;          
        var rowId = rowElement.id.split("__")[1];      
        var row = $find('<%= RadGrid1.ClientID %>').get_masterTableView().get_dataItems()[rowId];      
        alert(row.getDataKeyValue("ProductID"));     
    }  

Hope this helps..
Princy.
0
Enoch Kuang
Top achievements
Rank 1
answered on 02 Feb 2010, 02:20 PM
Cool, It's working! Thank you, Princy!
Tags
Grid
Asked by
Enoch Kuang
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Enoch Kuang
Top achievements
Rank 1
Share this question
or