sfDataGrid - howto ensure that the SelectedItem set by code is visible ?

sfDataGrid : howto ensure that the SelectedItem set by code is visible (in displayed scope) ?


3 Replies

SB Sweatha Bharathi Syncfusion Team February 12, 2024 02:46 PM UTC

Hi Frederic STECZYCKI ,


We have analyzed your query, and unfortunately, we are having difficulty in fully understanding your specific requirements. Could you please clarify if you need to set the value for the SelectedItem and disable it for a particular scenario? Kindly provide more details about your requirements. This will help us proceed further.



FS Frederic STECZYCKI February 13, 2024 09:13 AM UTC

Hi,

actually i need to set the focus on a cell (row/col) by code and ensure that this cell is visible on the screen for the user

(row is an sfDataGrid item, col is a sfDatagrid Column).



CM Chidanand Murugaiah Syncfusion Team February 14, 2024 10:16 AM UTC

Hi Frederic STECZYCKI,


We have analyzed your requirement of " how to ensure that a desired Item (or row) is visible on screen" can be achieved by using the ScrollInView method. You must pass the desired row column index as a parameter.


Kindly refer the below code snippet

  this.sfDataGrid.ScrollInView(new RowColumnIndex(30, 4));

You can also refer our online user guide documentation regarding the same by the following link.


UG linkhttps://help.syncfusion.com/winui/datagrid/selection#scroll-to-particular-rowcolumnindex



Another requirement of "get the focus on a chosen column" can be achieved by using the MoveToCurrentCell method. You must pass the chosen row column index as a parameter.

Kindly refer the below code snippet

this.sfDataGrid.MoveCurrentCell(new RowColumnIndex(30, 4));

You can also refer our online user guide documentation regarding the same by the following link.


UG linkhttps://help.syncfusion.com/winui/datagrid/selection#process-current-cell


We have attached the sample for your reference.

We hope this helps. Please let us know, if need any further assistance.


Note: -To ensure a particular row is visible during the initialization loading of SfDataGrid, it's advisable to invoke the methods within the 'sfDataGrid.Loaded' event.


Regards,

Chidanand M.


Attachment: SfDataGrid_Net_1b039db3.zip

Loader.
Up arrow icon