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

Correct way to implement DataGrid in PartialView

Hi there,

I am currently using EJ2 Grid as partial view components, so far it's working great. I am able to get and set the data successfully.

But I am now facing an issues where I can't get the correct selected record on 2nd load, where the grid will return me the value from 1st data set.

Details step below, with sample data.
  1. The grid is load with first set of data on load.
  2. Click on 1st row, return 1.
  3. Click on 4th row, return 4.
  4. Load the second set of data by clicking load button with filter text from input.
  5. Click on 1st row, return 1.
  6. Click on 4th row, return 8.
First set of data: { 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10 }
Second set of data: { 2, 4, 6, 8, 10 }

Attach is the code I used, is there anyway I am doing wrong on this or some additional setup are required for the partial view script to run on second load.

Attachment: Sample_f8f5faa7.zip

3 Replies

PS Pavithra Subramaniyam Syncfusion Team April 2, 2019 12:30 PM UTC

Hi Skye, 

Greetings from the Syncfusion support, 

We have analyzed the provided a code example and found that you have bounded the server returned result in innerHTML of Grid in Ajax.Success function from the loadData method. In this case, you have bound the result value to EJ2 Grid DOM Element instead of Grid dataSource. you can update the Grid’s dataSource using that result value. So that the Grid data will be refreshed and will provide the correct record on Grid row selection. Could you please provide more information about your query that will be helpful for us to provide a better solution as soon as possible. 

  1. Share the video to demonstrate the issue.
  2. Share the result returned from the ajax call.
  3. If possible share code example or sample for further analysis.
Pavithra S. 

SK Skye April 3, 2019 12:25 AM UTC


I actually manage to fixed this issue by using (args).

function rowSelected(args) {
            const index = args.rowIndex();

             var selectedrecord = args.data;



PS Pavithra Subramaniyam Syncfusion Team April 3, 2019 04:36 AM UTC

Hi Skye,  

Thanks for your update. 

We are happy to hear that you have resolved the issue. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Pavithra S. 

Live Chat Icon For mobile
Up arrow icon