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

Client script not working

6 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vairam
Top achievements
Rank 1
vairam asked on 28 Jan 2009, 09:41 AM
Hi

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

Sort by
0
Daniel
Telerik team
answered on 28 Jan 2009, 11:06 AM
Hello Vairam,

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.
0
vairam
Top achievements
Rank 1
answered on 28 Jan 2009, 11:51 AM
Hi

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



Thanks
Vairam
0
vairam
Top achievements
Rank 1
answered on 28 Jan 2009, 12:04 PM
Hi

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

 

0
Daniel
Telerik team
answered on 28 Jan 2009, 12:11 PM
Hello 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.
0
vairam
Top achievements
Rank 1
answered on 28 Jan 2009, 01:25 PM
Hi

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

0
vairam
Top achievements
Rank 1
answered on 28 Jan 2009, 02:29 PM
Hi

I used this link

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

My problem solved

Thanks
Vairam
Tags
Grid
Asked by
vairam
Top achievements
Rank 1
Answers by
Daniel
Telerik team
vairam
Top achievements
Rank 1
Share this question
or