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

Radgrid scrolling

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sushant
Top achievements
Rank 1
sushant asked on 05 Nov 2008, 07:31 AM
Hi All,

I am using radgrid to display records for more than one table,I am using scrolling,but when I display another table record scroll position remain on same position where I leave it when displaying first table record,I want scroll position on top each time grid bond,please help

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2008, 11:19 AM
Hello Sushant,

Try out the following code snippet to set the scroll position of the grid to the top.
aspx:
<ClientSettings>         
      <Scrolling AllowScroll="true" /> 
      <ClientEvents OnGridCreated="GridCreated" />         
</ClientSettings> 

js:
<script type="text/javascript"
 function GridCreated() 
  var RadGrid1 = $find("<%= RadGrid1.ClientID %>");  
    var row = RadGrid1.get_masterTableView().get_dataItems()[0]; 
  if (row) 
  { 
    setTimeout(function(){   
    var rowrowElement = row.get_element();    
    var scrollArea = RadGrid1.GridDataDiv; 
   if((rowElement.offsetTop - scrollArea.scrollTop) + 
       rowElement.offsetHeight + 20 > scrollArea.offsetHeight) 
   { 
        scrollAreascrollArea.scrollTop = scrollArea.scrollTop + (rowElement.offsetTop - scrollArea.scrollTop) + 
        (rowElement.offsetHeight - scrollArea.offsetHeight) + 
        rowElement.offsetHeight; 
   } 
     else if((rowElement.offsetTop - scrollArea.scrollTop) < 0
   { 
      scrollArea.scrollTop = rowElement.offsetTop; 
   } 
  }, 200); 
 } 
}  
}  
</script> 

Thanks
Princy.
Tags
Grid
Asked by
sushant
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or