Hi,
I'm just evaluating the RadControls an trying to figure out how to get the value of a cell from a RadGrid if I use ItemTemplates.
I read this article from the manual but it doesn't work as espected.
This is my grid and JS code:
I'm able to get the id, but the problem is, that all columns are displayed (I retrieve about 10 columns from DB while showing only 3) using the markup but I need to display a selection of them with a custom template and retrieving data of other columns which are not displayed (for instance ID).
If I define a new ItemTemplate after the closing <columns> tag the grid is displayed correctly but I cant access the id.
Cutting a long story short I'm looking for a clean and clientside way to access the content of specific cells which are not displayed.
I don't like something like <span style="display:none"> <%# Eval("ID")%></span> and MasterTable.getCellByColumnUniqueName(row, "Info").document.getElementByTagName('span')[int].innerHTML because this is a dirty workaround.
Any help is highly appreciated.
Kind regards Jay
I'm just evaluating the RadControls an trying to figure out how to get the value of a cell from a RadGrid if I use ItemTemplates.
I read this article from the manual but it doesn't work as espected.
This is my grid and JS code:
| function RowSelected(sender, eventArgs) { |
| var MasterTable = sender.get_masterTableView(); |
| var row = eventArgs.get_gridDataItem(); |
| alert(MasterTable.getCellByColumnUniqueName(row, "ID").innerHTML); |
| } |
| <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None" |
| Skin="Office2007" ShowHeader="False"> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| <ClientEvents OnRowSelected="RowSelected" OnRowCreated="RowCreated" /> |
| </ClientSettings> |
| <MasterTableView AllowAutomaticUpdates="True" DataSourceID="SqlDataSource1" HorizontalAlign="Left"> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="Other"> |
| <ItemTemplate> |
| <span style="display: block; float: left;"> |
| <%# Eval("by")%></span> <span style="display: block; float: right;"> |
| <%# Eval("date")%></span> |
| <br /> |
| <span style="font-weight: bold;"> |
| <%# Eval("subject")%> |
| </span> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn UniqueName="ID"> |
| <ItemTemplate> |
| <%# Eval("ID")%> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
I'm able to get the id, but the problem is, that all columns are displayed (I retrieve about 10 columns from DB while showing only 3) using the markup but I need to display a selection of them with a custom template and retrieving data of other columns which are not displayed (for instance ID).
If I define a new ItemTemplate after the closing <columns> tag the grid is displayed correctly but I cant access the id.
Cutting a long story short I'm looking for a clean and clientside way to access the content of specific cells which are not displayed.
I don't like something like <span style="display:none"> <%# Eval("ID")%></span> and MasterTable.getCellByColumnUniqueName(row, "Info").document.getElementByTagName('span')[int].innerHTML because this is a dirty workaround.
Any help is highly appreciated.
Kind regards Jay