I am using the bellow code in my user control but iam alway geting the this.ClientID =undifined
and this.MasterTableView.SelectedRows=null
what i need to chage this code?
<script type="text/javascript">
function GridCreated()
{
//gets the main table scrollArea HTLM element
var scrollArea = document.getElementById(this.ClientID + "_GridData");
var row = this.MasterTableView.SelectedRows[0];
//if the position of the selected row is below the viewable grid area
if((row.Control.offsetTop - scrollArea.scrollTop) + row.Control.offsetHeight + 20 > scrollArea.offsetHeight)
{
//scroll down to selected row
scrollArea.scrollTop = scrollArea.scrollTop + ((row.Control.offsetTop - scrollArea.scrollTop) + row.Control.offsetHeight - scrollArea.offsetHeight) + row.Control.offsetHeight;
}
//if the position of the the selected row is above the viewable grid area
else if((row.Control.offsetTop - scrollArea.scrollTop) < 0)
{
//scroll the selected row to the top
scrollArea.scrollTop = row.Control.offsetTop;
}
}
</script>
Thanks
Vairam
6 Answers, 1 is accepted
I attach a simple demo to this post. Please test it locally and let me know whether it works as expected on your end.
Note that it's compatible with RadControls for ASP.NET only.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I am using RadControls for ASP.NET AJAX.The below code work for RadControls for ASP.NET AJAX.
Thanks
Vairam

I have changed Register directive like this
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
I got this error
this
.MasterTableView.SelectedRows is null or not an object
Thanks
Vairam
I modified the first part of the code:
function GridCreated(sender, args) |
{ |
var scrollArea = document.getElementById(sender.ClientID + "_GridData"); |
if (sender.get_masterTableView().get_selectedItems().length > 0) |
{ |
var row = sender.get_masterTableView().get_selectedItems()[0]; |
... |
... |
} |
else |
alert("No rows selected"); |
} |
Hope this helps.
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Still i am getting error row.Control.offsetTop is null or not an object.
where can i get the code for the latest version.
function GridCreated(sender, args)
{
var scrollArea = document.getElementById(sender.ClientID + "_GridData");
alert(scrollArea);
if (sender.get_masterTableView().get_selectedItems().length > 0)
{
var row = sender.get_masterTableView().get_selectedItems()[0];
//if the position of the selected row is below the viewable grid area
if((row.Control.offsetTop - scrollArea.scrollTop) + row.Control.offsetHeight + 20 > scrollArea.offsetHeight)
{
//scroll down to selected row
scrollArea.scrollTop = scrollArea.scrollTop + ((row.Control.offsetTop - scrollArea.scrollTop) + row.Control.offsetHeight - scrollArea.offsetHeight) + row.Control.offsetHeight;
}
//if the position of the the selected row is above the viewable grid area
else if((row.Control.offsetTop - scrollArea.scrollTop) < 0)
{
//scroll the selected row to the top
scrollArea.scrollTop = row.Control.offsetTop;
}
}
else
alert(
"No rows selected");
}
Thanks
Vairam

I used this link
http://www.telerik.com/help/aspnet-ajax/grdscrolltotheselecteditem.html
My problem solved
Thanks
Vairam