Search and get rowindex from a line in SfGrid

Dear,


i have a grid with following fields. first column is ID i want to search in code for a particular id (for example where ID = 5) and get the rowindex and then position on that rowindex in the grid.

position on a particular rowindex in the grid is ok =>  await sfCourseGrid.SelectRowAsync(5);

But how can i search in data column ID = 5 and get the rowindex of that line? 


See sample below. 


              <SfGrid @ref="@sfCourseGrid" DataSource="@CourseList" EnableHeaderFocus="true" AllowSelection="true"

                    AllowSorting="true" AllowFiltering="true" AllowPaging="true" Width="100%" Height="100%"

                    AllowGrouping="true" AllowResizing="true" AllowReordering="true" ShowColumnChooser="true"

                    AllowExcelExport="true" AllowPdfExport="true"

                    Toolbar="Toolbaritems">


                    <GridSelectionSettings Mode=Syncfusion.Blazor.Grids.SelectionMode.Row></GridSelectionSettings>

                    <GridEvents OnToolbarClick="ToolbarClick" RowSelected="RowSelectHandler" TValue="CourseListDTO"></GridEvents>

                    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>

                    <GridPageSettings PageSize="100" PageCount="5"></GridPageSettings>


                    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>

                    <GridColumns>

                        <GridColumn Field=@nameof(CourseListDTO.CourseId) HeaderText="ID" TextAlign="TextAlign.Right" Width="80" Visible="true" AutoFit="true"></GridColumn>


                        <GridColumn Field=@nameof(CourseListDTO.CourseInternalType) HeaderText="Internal type" Width="200" Visible="true" AutoFit="true"></GridColumn>

                        <GridColumn Field=@nameof(CourseListDTO.CourseExternalType) HeaderText="External type" Width="200" Visible="true" AutoFit="true"></GridColumn>



3 Replies 1 reply marked as answer

KG Keerthana Ganesan Syncfusion Team December 16, 2022 10:38 AM UTC

Hi Chris,


Greetings from Syncfusion support.

We analyzed your query, and we suggest using the GetRowIndexByPrimaryKeyAsync method to achieve your requirement. Kindly refer to the attached document link for your reference.

Reference link: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_GetRowIndexByPrimaryKeyAsync_System_Object_

Kindly get back to us if you have any further queries.

Regards,

Keerthana.


Marked as answer

CV Chris Vandewiele March 27, 2023 12:40 PM UTC

Thanks

Chris Vandewiele



MS Monisha Saravanan Syncfusion Team March 28, 2023 03:06 AM UTC

Hi Chris,


Welcome. Kindly get back to us if you need further assistance. As always we will be happy to assist you.


Loader.
Up arrow icon