We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid SelectedRows are lost

Please note the attached video.
my Grid is in one component that is called from another component

Attachment: GridLoseSelectedRows_f0474dea.zip

1 Reply

VN Vignesh Natarajan Syncfusion Team February 6, 2020 07:06 AM UTC

Hi Ebi Torabi,  

Thanks for contacting Syncfusion support.  

Query: “my Grid is in one component that is called from another component 

By default Grid Selection cannot be persisted while destroying and re-rendering the component again. So we can achieve your requirement using GetSelectedRowIndexes() and SelectRows() method of EjsGrid. Refer the below code example.  

<EjsButton OnClick="Store">Save selection</EjsButton> 
<EjsButton OnClick="Load">Load selection</EjsButton> 
 
<EjsGrid @ref="Grid" DataSource="@Orders" AllowSelection="true" AllowSorting="true" AllowPaging="true">       
…. .. ..  
</EjsGrid> 
 
@code{ 
    EjsGrid<Order> Grid { getset; } 
    public List<double> SelectedIndexes = new List<double>();  
    public List<Order> Orders { getset; } 
    public async void Store() 
    { 
      SelectedIndexes = await Grid.GetSelectedRowIndexes(); 
    } 
    public async void Load() 
    { 
       await Grid.SelectRows(SelectedIndexes); 
    } 
. . . . .. . . . 
} 


Note: We have stored the selected index and applied the selected index using external button click. Similarly you can achieve your achieve your requirement by saving the selectedindexes while navigating to other page and apply the selection again to Grid using the stored the indexes again when Grid is rendered.   

Refer our API documentation for your reference 



Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon