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

How can get <telerik:GridBoundColumn> in javaScript function?

1 Answer 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 12 May 2012, 11:57 AM
I want to find  <telerik:GridBoundColumn DataField="ID" Visible="false" /> in javascript function.

please suggest for it.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 May 2012, 06:39 AM
Hello Sandeep,

You are not able to get Visible="false" column value on client side.

But you can achieve your requirement by using DataKey.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
       <script type="text/javascript">
           function ButtonClick() {
 
               var grid = $find("<%=RadGrid1.ClientID %>");
               var MasterTable = grid.get_masterTableView();
 
               var Rows = MasterTable.get_dataItems();
               for (var i = 0; i < Rows.length; i++) {
                   var row = Rows[i];
                   alert(row.getDataKeyValue('ID'));
               }
 
 
           }
            
       </script>
   </telerik:RadCodeBlock>
.
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
        >
            <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID">
                <Columns>
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return ButtonClick(); return false;" />

protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
      {
          dynamic data = new[] {
            new { ID = 1, Name ="name1"},
            new { ID = 2, Name = "name2"},
            new { ID = 3, Name = "name3"},
            new { ID = 4, Name = "Name4"},
             new { ID = 5, Name ="name5"}};
          RadGrid1.DataSource = data;
      }






Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or