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

Accessing Mastertableview for radgrid on page load

7 Answers 344 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avik
Top achievements
Rank 1
Avik asked on 30 Jul 2008, 06:16 AM
Hi,
    I am using a Telerik radgrid for asp.net ajax in a ascx page.I have register a JS function in the page load of the ascx where in i am not able to find the Master TableView of the radgrid in the function .The code in the JS function is as below .
 var radgrid = <%=radGrid1.ClientID%>;
i am not able to get the master table view for the radgrid. i even tried $get("<%=radGrid1.ClientID%>") but in vain.

Can anyone let me know the fix for the above issue.

Thanks,
Avik.

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jul 2008, 08:23 AM
Hello Avik,

Can you try using the following JavaScript code and see if it helps?

ascx:
var grid = $find("<%=RadGrid1.ClientID %>"); 
var MasterTable = grid.MasterTableView; 

Thanks
Princy.
0
Avik
Top achievements
Rank 1
answered on 30 Jul 2008, 08:38 AM
Hi Princy,
    Thanks for your reply.I tried what you said but it is not able to find the control .When i debugged, the control is null.I think since the javascript is being called from the page load the $find syantax is not working.
    When we were using radgrid for asp.net ,in the same JS function we use to get the master table by using the following code 
     var radgrid = <%=radGrid1.ClientID%>;
     radgrid.Iw.MasterTableView used to give us the master table .
I am not able to find the equivalent of the same in radgrid for asp.net ajax.


Thanks,
Avik.


0
Avik
Top achievements
Rank 1
answered on 30 Jul 2008, 10:16 AM
Hi,
    Please, Can anyone from Telerik team provide a fix for the issue.Its very urgent since we are doing a migration from asp.net rad controls to asp.net ajax controls.



Thanks,
Avik.
0
Sebastian
Telerik team
answered on 30 Jul 2008, 10:42 AM
Hello Avik,

Here is the code that should work properly for you:

var grid = $find("<%=RadGrid1.ClientID %>"); 
var MasterTable = grid.get_masterTableView(); 

You may also be interested in reviewing the following topic from the online documenation which is dedicated to speed up the migration process between the Classic and the ASP.NET AJAX version of the grid:

http://www.telerik.com/help/aspnet-ajax/grdmigrationtoprometheus.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Avik
Top achievements
Rank 1
answered on 30 Jul 2008, 10:58 AM
Hi Stephen,
    Thanks for your reply.Before posting this query ,i  had tried what you had suggested, but $find is not working .The JS function in which i am using the syntax is not able to find the radgrid control.

The JS function what i am talking about is registered in the Page Load event of the page and may be because of that $find is not working.

When we were using radgrid for asp.net ,in the same JS function we use to get the master table by using the following code 
     var radgrid = <%=radGrid1.ClientID%>;
     radgrid.Iw.MasterTableView used to give us the master table .
I am not able to find the equivalent of the same in radgrid for asp.net ajax.
I am very much aware of the fact that in radgrid for asp.net ajax we have to use the get_masterTableView(), but it throws an null error when i do the same in the JS function.But for a RowClick JS function get_masterTableView()  works well.

Thanks,
Avik.


0
Avik
Top achievements
Rank 1
answered on 30 Jul 2008, 12:44 PM

Hi All,
Adding some more details to the issue raised by me.In my page if the Request Query String contains the value for productid then a javascript function is registered in the paeg load and that will get fired in the page load itself.The code is as below...


if

(!string.IsNullOrEmpty(productid))
this.Page.RegisterStartupScript("scriptKey", "<script>PopulateonLoad('" + productid + "','" + SourceCode + "');</script>");

The JS function that will be called is as below....
function PopulateonLoad(productid,promotionCode)
{

//debugger

;
var gridload = <%=RadGrid1.ClientID %>;
var gridload1 = $find("<%=RadGrid1.ClientID %>");
//gridload1 is showing as null
var gridload2 = $get("<%=RadGrid1.ClientID %>");
var ProductID = null;
for (i=0;i<gridload.Iw.MasterTableView.Controls[0].Rows.length;i++)
{
var row0 = gridload.Iw.MasterTableView.Controls[0].Rows[i];
if(typeof row0.KeyValues != 'undefined')
{
ProductID = row0.KeyValues[
"ProductID"];
if(ProductID == productid)
{
row0.Selected =
true;//
row0.Expanded = true;//
Populate(ProductID,promotionCode);
}
}
}

}
I want to know the equivalent of the highlighted(red) one in radgrid for asp.net ajax controls because the highlighted one works well in radgrid for asp.net.

Hoping that someone can help me out.

Thanks,
Avik.

0
david
Top achievements
Rank 1
answered on 24 Sep 2008, 01:27 PM
I'm having the same problem in an .ascx (no problem in a .aspx).  Did you ever find /get a resolution?

thanks
Tags
Grid
Asked by
Avik
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Avik
Top achievements
Rank 1
Sebastian
Telerik team
david
Top achievements
Rank 1
Share this question
or