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

get the controls inside radgrid in javascript

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Regeesh Joseph
Top achievements
Rank 1
Regeesh Joseph asked on 04 Jun 2012, 06:11 AM
Hai,

I have a radgrid.

<

 

 

Columns>

 

 

 

<telerik:GridTemplateColumn HeaderText="SlNo">

 

 

 

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="true" Width="4%" />

 

 

 

<ItemStyle HorizontalAlign="Center" Width="4%" />

 

 

 

<ItemTemplate>

 

<%

 

# this.rgByAirline.CurrentPageIndex * this.rgByAirline.PageSize + Container.ItemIndex + 1%>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

<telerik:GridBoundColumn DataField="Recipe_Id" HeaderText="Recipe_Id" Visible="false">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridTemplateColumn HeaderText="Recipe">

 

 

 

<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Font-Bold="true" Width="96%" />

 

 

 

<ItemStyle HorizontalAlign="Left" Width="96%" />

 

 

 

<ItemTemplate>

 

 

 

<asp:LinkButton ID="lnkRecipe" runat="server" ToolTip="Click here to see details of the Recipe"

 

 

 

CommandName="PopupWindow" OnClientClick="return PopupWindow(this);" Text='<%#Eval("Recipe_Description") %>'></asp:LinkButton>

 

 

 

<asp:Label ID="ltrRecipeId" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"Recipe_Id") %>'></asp:Label>

 

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

</Columns>

I want to get the Recipe_Id in the javascript PopupWindow(this);

 

 

 

function PopupWindow(anc) {

 

 

 

debugger;

 

 

 

var rowIndex = anc.parentElement.parentElement.rowIndex;

 

 

 

var grdRowNo = Number(isNaN(rowIndex) ? 0 : rowIndex) + 1;

 

 

 

 

 

 

 

 

 

 

var strTransLblId = 'ctl00_CphMaster_rgByAirline' + ((grdRowNo <= 9) ? '_ctl00_ctl0' : '_ctl00_ctl') + grdRowNo + '_ltrRecipeId';

 

 

 

var intRecipeId = Number(document.getElementById(strTransLblId).innerText);

 

 

 

var oWnd = radopen("FKMS_MMS_Recipe_Detail_Popup.aspx?intRecipeId=" + intRecipeId, "RadWindowPopup");

 

oWnd.setSize(725, 600);

 

 

return false;

 

}

 

I got the row number correctly.
But it shows null reference exception in the following line.

var intRecipeId = Number(document.getElementById(strTransLblId).innerText);

Please help urgently.

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Jun 2012, 06:35 AM
Hello Regeesh,

One suggestion is you can set the Display property of the column as false and access it using getCellByColumnUniqueName method. Here is the sample code.
JS:
var master = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
var row = master.get_dataItems()[0];
var cell = master.getCellByColumnUniqueName(row, "Recipe_Id");
alert(cell.innerHTML);

Thanks,
Shinu.
Tags
Grid
Asked by
Regeesh Joseph
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or