Hi,
i got a grid in a radwindow and i want to return the id of the selected row dataitem.
The id is in the MAsterView DataKeyvalue and i also tried to put it in a invisible column with unique name id..
I want to do it client side with java script as i already have used JS by opening the Radwindow.
After i read the references in the online documentary i got following code:
With this i get an page error that "null is Null, or not an object". Its also not working with sell.innerHtml without ().
i also used this inline outcommented way/line, but then i come to the false alert.
Here the grid:
The radwindow works fine and the grid has mutli select disabled and row select allowed
Any ideas why im not able to retrieve the id of the selected row?
cheers mario
i got a grid in a radwindow and i want to return the id of the selected row dataitem.
The id is in the MAsterView DataKeyvalue and i also tried to put it in a invisible column with unique name id..
I want to do it client side with java script as i already have used JS by opening the Radwindow.
After i read the references in the online documentary i got following code:
<telerik:RadCodeBlock ID="radCodeBlock" runat="server"> |
<script type="text/javascript"> |
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function returnToParent() |
{ |
//create the argument that will be returned to the parent page |
var oArg = new Object(); |
//get the selected id from RadGrid |
var grid = $find("<%=radGrid.ClientID %>"); |
var MasterTable = grid.get_masterTableView(); |
var selectedRows = MasterTable.get_selectedItems(); |
for (var i = 0; i < selectedRows.length; i++) |
{ |
alert(i); // got 0 for 1 selectec row |
var row = selectedRows[i]; |
var cell = MasterTable.getCellByColumnUniqueName(row, "id") |
} |
var id = cell.innerHtml(); |
//var id = $find("<%=radGrid.ClientID %>").get_masterTableView().get_selectedItems()[0].getDataKeyValue("id"); |
//get a reference to the current RadWindow |
var oWnd = GetRadWindow(); |
//Close the RadWindow and send the argument to the parent page |
if(id) |
{ |
//oWnd.close(oArg); |
alert("docid = " + id); |
} |
else |
{ |
alert("Please select a document."); |
} |
} |
</script> |
</telerik:RadCodeBlock> |
With this i get an page error that "null is Null, or not an object". Its also not working with sell.innerHtml without ().
i also used this inline outcommented way/line, but then i come to the false alert.
Here the grid:
<telerik:RadGrid ID="radGrid" runat="server" |
AllowPaging="True" |
PageSize="20" |
AutoGenerateColumns="False" |
GridLines="Both" |
AllowMultiRowSelection = "false" |
ClientSettings-Selecting-AllowRowSelect = "true" |
OnNeedDataSource="Radgrid_NeedDatasource"> |
<MasterTableView DataKeyNames="id" |
CommandItemDisplay="Top"> |
<CommandItemTemplate> |
<div style="padding: 5px 5px;"> |
<img onclick="returnToParent()" style="border:0px;vertical-align:middle;" alt="" src="../App_Themes/Default/Images/file_icon.gif"/> |
<asp:Label ID="lblChooseDocument" runat="server" Text="choosedocument" OnLoad="OnLabelLoad"></asp:Label> |
</div> |
</CommandItemTemplate> |
<Columns> |
<telerik:GridBoundColumn DataField="id" Visible="false"></telerik:GridBoundColumn> |
<telerik:GridTemplateColumn> |
<ItemTemplate> |
<asp:Image runat="server" ID="imgNew" |
OnLoad="OnImageLoad" /> |
<asp:TextBox ID="txbCreatedDate" runat="server" |
Visible ="false" |
Text='<%# DataBinder.Eval(Container.DataItem,"created_date").ToString() %>' /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridHyperLinkColumn DataTextField="Metainformation.name" HeaderText="Profile" DataTextFormatString="{0}"></telerik:GridHyperLinkColumn> |
<telerik:GridBoundColumn DataField="Category.name" HeaderText="Kategorie"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="User.lastname" HeaderText="Ersteller"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="created_date" HeaderText="Erstellungsdatum"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="User1.lastname" HeaderText="letzter Bearbeiter"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="checkout_date" DataType="System.DateTime" HeaderText="in Verwendung seit"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Folder.name" HeaderText="Ordner"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="id" UniqueName="id" Visible="false"></telerik:GridBoundColumn> |
</Columns> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
</MasterTableView> |
</telerik:RadGrid> |
The radwindow works fine and the grid has mutli select disabled and row select allowed
Any ideas why im not able to retrieve the id of the selected row?
cheers mario