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

Access hidden column

6 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 02 Feb 2012, 09:35 PM
I am using the code you guys have posted on this page = http://www.telerik.com/help/aspnet-ajax/grid-getting-cell-values-for-selected-rows-client-side.html . It works great as long as my column is set to visible = true. when I hide the id column the javascript cannot access the value. Is there a solution to this? Basically what I am doing is allowing the user to select the entire row, I then grab the ID column and send them to a reporting page with this ID set as a querystring.

Here is the aspx page code:

<script type="text/javascript" >
 
    function RowSelected(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "videoID");
        window.location = "Map.aspx?id=" + cell.innerHTML;
        //here cell.innerHTML holds the value of the cell 
    }
     
</script>
    <style type="text/css" >
       
    .RowMouseOver 
    
      background-color: red !important; 
    
        
    </style>
    <table width="900" align="center">
<tr>
<td>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    </td>
</tr>
<tr>
<td align="center">
 
    <telerik:RadGrid ID="RadGrid1"  runat="server"
        AllowPaging="True" DataSourceID="sdsVideoList"
        AllowMultiRowSelection="True" ShowFooter="True" ShowStatusBar="True"
        AllowSorting="True" CellSpacing="0" GridLines="None" Skin="Telerik"
        AutoGenerateColumns="False">
         <ClientSettings EnableRowHoverStyle="true" >
               
              <Selecting AllowRowSelect="true" />
              <ClientEvents OnRowSelected="RowSelected" />
 
            </ClientSettings>
     
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridBoundColumn DataField="videoID" Visible="true"
            FilterControlAltText="Filter column column" HeaderText="videoID"
            UniqueName="videoID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Name"
            FilterControlAltText="Filter column1 column" HeaderText="Name"
            UniqueName="column1">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CreatedOn"
            FilterControlAltText="Filter column2 column" HeaderText="Date Created"
            UniqueName="column2">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="wisitaID" Visible="false"
            FilterControlAltText="Filter column3 column" HeaderText="Wisita ID"
            UniqueName="column3">
        </telerik:GridBoundColumn>
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
    </telerik:RadGrid>


Thanks!
Sam

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2012, 05:00 AM
Hello Sam,

When you are setting the visibility of column as false, you can access it using ClientDataKeyNames property. Here is the sample code.
Javascript:
function RowSelected(sender, args)
 alert(args.getDataKeyValue("videoID"));
}
Note:Set MasterTableView- ClientDataKeyNames as videoID.

-Shinu.
0
Sam
Top achievements
Rank 1
answered on 01 Mar 2012, 09:22 PM
I tried it and it gave me a "cell is null" error. Also is there a way to make the pointer into the traditional finger so people know it's clickable? right now it doesn't show this.

Heres the code:

function RowSelected(sender, eventArgs) {
       var grid = sender;
       var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
       var cell = eventArgs.getDataKeyValue("videoID");
       var name = eventArgs.getDataKeyValue("name");
       window.location = "Map_New.aspx?vid=" + cell.innerHTML + "&n=" + name.innerHTML + "&c=Map";
 
   }
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2012, 05:50 AM
Hello,

Try the following CSS .
CSS:
.rgAltRow, .rgRow
{
 cursor: pointer !important;
}

-Shinu.
0
Sam
Top achievements
Rank 1
answered on 02 Mar 2012, 03:48 PM
thanks for the help. Anyone know how to fix the accessing a hidden column via javascript problem I am having?

0
Accepted
Casey
Top achievements
Rank 1
answered on 02 Mar 2012, 04:14 PM
Hi Sam,

I know that I've had issues with using visible = false when using RadAjaxManager, and I've got around that by setting Display=false instead. Maybe setting the Display property instead of the Visible property will help fix your problem.

I hope this helps!
Casey
0
Sam
Top achievements
Rank 1
answered on 02 Mar 2012, 05:01 PM
That worked. Thanks Casey!!!

Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sam
Top achievements
Rank 1
Casey
Top achievements
Rank 1
Share this question
or