Get datagrid row details on check of checkbox

i have grid with column checkbox, on check of the checkbox i need to retrive the row details in the grid.

Sample code 


                <SfGrid @ref="DefaultGrid" DataSource="@GridData" AllowPaging="true" AllowGrouping="true" Toolbar="toolbar" AllowSelection="true">

                    <GridGroupSettings Columns=@GroupedColumn></GridGroupSettings>

                   <GridEvents RowSelected="RowSelectHandler" RowDeselected="RowDeselectHandler" TValue="ProjectSite"></GridEvents>

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


                    <GridEditSettings AllowEditing="true">

                        <FooterTemplate>

                            <SfButton>Savef</SfButton>

                            <SfButton>Cancelf</SfButton>

                        </FooterTemplate>

                    </GridEditSettings>

                    <GridColumns>

                        <GridColumn Field=@nameof(ProjectSite.ProgramProjectSiteId) HeaderText="ProgramProjectSiteId" Width="150" Visible=false IsPrimaryKey="true"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.SiteId) HeaderText="SiteId" Width="210" Visible=false></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.SiteAssetId) HeaderText="SiteAssetId" Width="170" Visible=false></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.SiteOpenIssueId) HeaderText="SiteOpenIssueId" TextAlign="TextAlign.Right" Width="170" Visible=false></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.ProjectTypeId) HeaderText="SiteOpenIssueId" TextAlign="TextAlign.Right" Width="170" Visible=false></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.Level1) HeaderText="Level1" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.SiteName) HeaderText="SiteName" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.Level2) HeaderText="Level2" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.Level3) HeaderText="Level3" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.RemoteType) HeaderText="RemoteType" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.Origin) HeaderText="Origin" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.State) HeaderText="State" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.Owner) HeaderText="Owner" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.IssueId) HeaderText="IssueId" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.IssueType) HeaderText="IssueType" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.LastInspectionDate) HeaderText="LastInspectionDate" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.ReviewInspectionDate) HeaderText="ReviewInspectionDate" TextAlign="TextAlign.Right" Width="170"></GridColumn>

                        <GridColumn Field=@nameof(ProjectSite.ResultId) HeaderText="ResultId" Width="120" Type="ColumnType.CheckBox" TextAlign="TextAlign.Center"></GridColumn>

                    </GridColumns>

                </SfGrid>


Please let me know what events are required on this.


1 Reply

MS Monisha Saravanan Syncfusion Team February 14, 2022 11:34 AM UTC

Hi Ajay, 

Greetings from Syncfusion support. 

Query: “I have grid with column checkbox, on check of the checkbox i need to retrive the row details in the grid. what events are required on this” 

When checkbox column is clicked, OnRecordClick, RowSelecting, RowSelected events will be triggered. You can use any one of these events to retrieve the row data while clicking an checkbox column. We can get row data information on the event args. Kindly refer the below code snippet and documentation for your reference. 

 
<SfGrid DataSource="@Orders" AllowSelection="true" AllowPaging="true"> 
    <GridSelectionSettings Type="SelectionType.Multiple"></GridSelectionSettings> 
     <GridEvents RowSelecting="RowSelectingHandler" RowSelected="RowSelectHandler" OnRecordClick="RecordClickHandler" TValue="Order"></GridEvents> 
 
    <GridColumns> 
... 
    </GridColumns> 
</SfGrid> 
 
@code{ 
     
    public void RowSelectingHandler(RowSelectingEventArgs<Order> args) 
    { 
        // Here you can customize your code 
    } 
    public void RowSelectHandler(RowSelectEventArgs<Order> args) 
    { 
        // Here you can customize your code 
    } 
     public void RecordClickHandler(RecordClickEventArgs<Order> args) 
    { 
        // Here you can customize your code 
    } 
} 


Kindly get back to us if you have further queries. 

Regards, 
Monisha 


Loader.
Up arrow icon