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

Getting values from a grid column that is not visible

2 Answers 430 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asok
Top achievements
Rank 1
Asok asked on 26 Oct 2009, 10:09 AM
Hello,

I need to get the cell value of a grid column that I have set to false. When I make it visible true, I am getting the values. I am using the client side script to get the value when clicking the check box in the grid.

The below is the javascript function I use to ge the value

 

 

 

function getGridCheckedValues(){   
   var grid = $find("<%=RadGrid1.ClientID %>");   
   var MasterTable = grid.get_masterTableView();   
   var selectedRows = MasterTable.get_selectedItems();   
  for (var i = 0; i < selectedRows.length; i++){  
  var row = selectedRows[i];   
  var cell = MasterTable.getCellByColumnUniqueName(row, "fld_id");  
  alert(cell.innerHTML);   
 
  }  
 
   
 
}  
 
 
 

This is the code I use in the HTML. Please note the column "fld_id".

 

 

 

 

<telerik:RadGrid AllowSorting="True" ID="RadGrid1" AllowPaging="True" runat="server" Skin="Vista" 
 
 
 
GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" AutoGenerateColumns="False" 
 
 
 
ShowDesignTimeSmartTagMessage="False" Width="800" OnSortCommand="RadGrid1_SortCommand" AllowMultiRowSelection="true" 
 
 
 
OnNeedDataSource="RadGrid1_NeedDataSource" OnPageIndexChanged="RadGrid1_PageIndexChanged">  
 
 
 
<MasterTableView TableLayout="Auto" DataKeyNames="fld_id">   
 
<Columns>   
 
<telerik:GridBoundColumn DataField="fld_id" HeaderText="Id" SortExpression="fld_id" 
 
 
 
UniqueName="fld_id" ReadOnly="true" Visible="false">  
 
 
 
<HeaderStyle Width="0px" /> 
 
 
 
</telerik:GridBoundColumn> 
 
 
 
<telerik:GridClientSelectColumn UniqueName="fld_id" /> 
 
 
 
<telerik:GridBoundColumn DataField="fld_firstname" ReadOnly="True" HeaderText="<%$Resources:WSPL, FirstName %>" 
 
 
 
SortExpression="fld_firstname" UniqueName="fld_firstname">  
 
 
 
<HeaderStyle Width="150px" /> 
 
 
 
<ItemStyle Width="150px" /> 
 
 
 
</telerik:GridBoundColumn>   
 
<telerik:GridBoundColumn DataField="fld_lastname"   
 
ReadOnly="True" HeaderText="<%$Resources:WSPL, LastName %>" UniqueName="fld_lastname">  
 
 
 
<HeaderStyle Width="150px" /> 
 
 
 
<ItemStyle Width="150px" /> 
 
 
 
</telerik:GridBoundColumn> 
 
 
 
<telerik:GridBoundColumn DataField="fld_email"   
 
ReadOnly="True" HeaderText="<%$Resources:WSPL, Email %>" UniqueName="fld_email">  
 
 
 
<HeaderStyle Width="150px" /> 
 
 
 
<ItemStyle Width="150px" /> 
 
 
 
</telerik:GridBoundColumn> 
 
 
 
<telerik:GridBoundColumn DataField="fld_country" ReadOnly="True" HeaderText="<%$Resources:WSPL, Country %>" 
 
 
 
SortExpression="fld_country" UniqueName="fld_country">  
 
 
 
<HeaderStyle Width="120px" /> 
 
 
 
<ItemStyle Width="120px" /> 
 
 
 
</telerik:GridBoundColumn>   
 
<telerik:GridBoundColumn DataField="fld_wingspan" ReadOnly="True" HeaderText="<%$Resources:WSPL, WingSpan %>" 
 
 
 
SortExpression="fld_wingspan" UniqueName="fld_wingspan">  
 
 
 
<HeaderStyle Width="120px" /> 
 
 
 
<ItemStyle Width="120px" /> 
 
 
 
</telerik:GridBoundColumn>   
 
<telerik:GridTemplateColumn Resizable="False" UniqueName="TemplateColumn2">  
 
 
 
<HeaderStyle Width="30px" /> 
 
 
 
<ItemStyle Width="30px" /> 
 
 
 
<ItemTemplate> 
 
 
 
<asp:ImageButton ToolTip="<%$Resources:WSPL, ClickToView %>" ImageUrl="~/img/zoom.gif" 
 
 
 
CommandName="viewCoach" runat="server" ID="img_View" /> 
 
 
 
</ItemTemplate> 
 
 
 
</telerik:GridTemplateColumn>   
 
</Columns>   
 
</MasterTableView>   
 
<ClientSettings EnableRowHoverStyle="true">  
 
 
 
<ClientEvents OnRowDblClick="RowDblClick" OnGridCreated="GridCreated" /> 
 
 
 
<Selecting AllowRowSelect="True" />   
 
</ClientSettings>   
 
<PagerStyle Mode="NumericPages" />   
 
</telerik:RadGrid> 
 
 
 
 
 

Thanks in advance.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Oct 2009, 11:14 AM
Hello Asok,

Try setting the Display property of the column to false, rather than setting the visible property and hence you will be able to access the cell value:
aspx:
<telerik:GridBoundColumn DataField="fld_id" HeaderText="Id" SortExpression="fld_id" UniqueName="fld_id" ReadOnly="true" Display="false"
<HeaderStyle Width="0px" />  
</telerik:GridBoundColumn> 

Hope this helps..
Shinu.
0
Asok
Top achievements
Rank 1
answered on 26 Oct 2009, 11:20 AM
Hello Shinu,

Thank you so much!. It really helped.
Tags
Grid
Asked by
Asok
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Asok
Top achievements
Rank 1
Share this question
or