Programmatic selection using the SelectRows method is not supported in virtual scrolling

Programmatic selection using the SelectRows method is not supported in virtual scrolling, is there any plan to support this in the future?


1 Reply

VN Vignesh Natarajan Syncfusion Team October 13, 2021 05:15 AM UTC

Hi Niels,  
 
Thanks for contacting Syncfusion support.  
 
Query: “Programmatic selection using the SelectRows method is not supported in virtual scrolling, is there any plan to support this in the future? 
 
Yes, we do not have direct support to select the record programmatically in virtualized record. But we can achieve this requirement using the below solution. We have scrolled to specific height and used SelectRows() method to achieve your requirement. Scroll Height is calculated based on the record index and static Grid row height.  
 
Refer the below code example.  
 
<SfNumericTextBox TValue="double" @bind-Value="@Value"></SfNumericTextBox> 
  
<SfButton Content="Select" OnClick="Clicked"></SfButton> 
  
<SfGrid @ref="GridInstance" DataSource="@GridData" Height="600" EnableVirtualization="true"> 
. . . . . . . . . .  
</SfGrid> 
  
@code{ 
    public SfGrid<Order> GridInstance { getset; } 
  
    public double Value { getset; } = 0; 
  
    public List<Order> GridData { getset; } 
  
    public async Task Clicked() 
    { 
        await Runtime.InvokeAsync<object>("scroll", Value, GridInstance.RowHeight != 0 ? GridInstance.RowHeight : 37 ); 
        await Task.Delay(500); 
        await GridInstance?.SelectRow(Value); 
    } 
 
[Scroll.js] 
 
function scroll(index, rowHeight){    var grid = document.getElementsByClassName("e-grid")[0];    grid.querySelector('.e-content').scrollTop = (index - 1) * rowHeight;}
 
 
Kindly refer the below sample for your reference 
 
 
Please get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon