New row hidden

Hello

I have an SfDataGrid in which I load thousands of records and obviously not all of them are displayed.

If I add a new record, I'd like to position over it and to do that I use the ScrollInView method.


The record is selected correctly but remains hidden.

Some more scrolling is needed to make it visible.


Basically, the ScrollInView positions itself correctly on the record but scrolls only to the second to last record and therefore the last one remains hidden.


So, how can I make the newly added record visible immediately at the end of the list?


In addition I may have also encountered a bug.

When I select the first record, as RecordIndex I get returned the value -1.

Which seems strange to me.


Attached is the test project


Regards

Michele


Attachment: TestSfDataGridSolution_612b052.zip

3 Replies 1 reply marked as answer

SP Sreemon Premkumar Muthukrishnan Syncfusion Team July 13, 2023 04:41 PM UTC

Hi Michele,

We have analyzed the sample you have provided. The record collection consists of rows, excluding the header row. The RowIndex has the index value that includes the header row. We have modified the sample by assigning the RecordIndex property with the last index of the record collection and we calculate the index value for the RowIndex property by using the ResolveToRowIndex method, by passing the recordIndex. Please find the code snippet below,


//Getting the index of the last item of the record collection and assigned it to the RecordIndex property.

var recordIndex = records.IndexOf(item);

RecordIndex = recordIndex;

 

//Then calculating the RowIndex by passing the record index.

var rowIndex = Grid.ResolveToRowIndex(recordIndex);

RowIndex = rowIndex;


We have modified the sample you have provided, please find it in the attachment.

Regards,

Sreemon Premkumar M.


Attachment: TestSfDataGridSolution_96f2c72a.zip

Marked as answer

MI Michele July 14, 2023 06:15 AM UTC

Thanks  Sreemon 

It works


Regards

Michele




SB Sweatha Bharathi Syncfusion Team July 17, 2023 01:37 PM UTC

Michele ,


We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.


Loader.
Up arrow icon