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
close icon

TreeGrid events for CRUD

Can you pleae point me to the documentation on how to capture the event for CRUD? 

I have looked at the RowSelected and RowSelecting events; however, they don't tell us which operation is being conducted. For example, if using the command buttons in the row, how do I know if the user clicked the edit button, the save button, or the delete button? 

    < EjsTreeGrid ID="TreeGrid" @ref="TreeGrid" DataSource="@TreeData" IdMapping="OrgUnitId" ParentIdMapping="ParentOrgUnitId" TreeColumnIndex="4"
                 AllowPaging="true" AllowExcelExport="true" AllowFiltering="true" AllowMultiSorting="true" AllowPdfExport="true"
                 AllowReordering="true" AllowResizing="true" AllowRowDragAndDrop="true" AllowSorting="true" AutoCheckHierarchy="true"
                 EnableAltRow="true" EnableCollapseAll="true" EnableHover="true" ShowColumnMenu="true"
                 Toolbar="Toolbaritems">
        < TreeGridEvents TValue="Node" OnToolbarClick="Toolbarclick" RowSelected="RowSelectHandler" RowSelecting="RowSelectingHandler"></TreeGridEvents>
        < TreeGridSelectionSettings Type="Syncfusion.EJ2.Blazor.Grids.SelectionType.Single" Mode="Syncfusion.EJ2.Blazor.Grids.SelectionMode.Row">
< /TreeGridSelectionSettings>
        <TreeGridPageSettings PageSizeMode="PageSizeMode.Root" PageSize="50"></TreeGridPageSettings>
        <TreeGridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.EJ2.Blazor.TreeGrid.EditMode.Row" >
< /TreeGridEditSettings>
        < TreeGridFilterSettings Type="Syncfusion.EJ2.Blazor.TreeGrid.FilterType.Menu"></TreeGridFilterSettings>
        < TreeGridColumns>
            < TreeGridColumn HeaderText="" Width="15" Commands="commands" AllowReordering="false" AllowSorting="false" AllowResizing="false"> 
< /TreeGridColumn>
            < TreeGridColumn Field="Id" HeaderText="Id" Width="100" IsPrimaryKey="true" Visible="false" AllowEditing="false"></TreeGridColumn>
            < TreeGridColumn Field="ParentId" HeaderText="ParentId" Width="100" Visible="false" AllowEditing="false"></TreeGridColumn>
            < TreeGridColumn Field="Code" HeaderText="Code" Width="20"></TreeGridColumn>
            < TreeGridColumn Field="Name" HeaderText="Name" Width="40"></TreeGridColumn>
        < /TreeGridColumns>
    < /EjsTreeGrid>

        protected async void RowSelectHandler(Syncfusion.EJ2.Blazor.Grids.RowSelectEventArgs<Node> Args)
{
          this.SelectedRowIndexes = await this.TreeGrid.GetSelectedRowIndexes();   /// get the selected row indexes
          this.SelectedRecords = await this.TreeGrid.GetSelectedRecords();   /// get the selected records

          // What CRUD action was clicked??
}

9 Replies

MP Manivannan Padmanaban Syncfusion Team January 17, 2020 10:15 AM UTC

Hi Scott, 

Greetings from Syncfusion Support. 

Query: Can you please point me to the documentation on how to capture the event for CRUD?  
 
Using ActionComplete event of TreeGrid, we can able to capture the CRUD actions. Refer the below code example, 

<EjsTreeGrid ………….> 
………………………. 
   <TreeGridEvents  OnActionComplete="Complete" TValue="TreeData.BusinessObject"></TreeGridEvents> 
 
    <TreeGridColumns> 
………………… 
    </TreeGridColumns> 
</EjsTreeGrid> 
@code{ 
………………………. 
 
 
    private void Complete(ActionEventArgs<TreeData.BusinessObject> args) 
    { 
        if (args.RequestType.ToString() == "Add") 
        { 
           //Do your stuff here. 
        } 
        if (args.RequestType.ToString() == "BeginEdit") 
        { 
            // Do your stuff here. 
        } 
        if (args.RequestType.ToString() == "Save") 
        { 
            // Do your stuff here. 
        } 
        if (args.RequestType.ToString() == "Delete") 
        { 
            // Do your stuff here. 
        } 
    } 
} 

Also, refer the below API link. 

Kindly get back to us, if you need further assistance. 

Regards, 
Manivannan Padmanaban. 



SP Scott Peal January 17, 2020 01:05 PM UTC

Fantastic!

BTW, that link to the properties is what I have been missing for finding the events!

Thanks again...


GL Gowri Loganathan Syncfusion Team January 20, 2020 08:30 AM UTC

Hi Scott, 
  
Thanks. 
  
Please revert us, if you need any queries. We will happy to assist you. 
  
Regards, 
Gowri V L. 



SP Scott Peal January 21, 2020 03:06 PM UTC

Hello,
It seems the save and delete action events are not firing. It is firing and catching the BeginEdit and Cancel events though. Can the devs validate the save and delete events are firing on their side?

        protected void ActionComplete(Syncfusion.EJ2.Blazor.Grids.ActionEventArgs args)
        { 
            if (args.RequestType.ToString() == "Add")
            {
                //Do your stuff here. 
            }
            if (args.RequestType.ToString() == "BeginEdit")
            {
                // Do your stuff here. 
            }
            if (args.RequestType.ToString() == "Save")
            {
                // Do your stuff here. 
            }
            if (args.RequestType.ToString() == "Delete")
            {
                // Do your stuff here. 
            }
        }


    < EjsTreeGrid ID="TreeGrid" @ref="TreeGrid" DataSource="@TreeData" IdMapping="OrgUnitId" ParentIdMapping="ParentOrgUnitId" TreeColumnIndex="1"
                 AllowPaging="true" AllowExcelExport="true" AllowFiltering="true" AllowMultiSorting="true" AllowPdfExport="true"
                 AllowReordering="true" AllowResizing="true" AllowRowDragAndDrop="true" AllowSorting="true"
                 EnableAltRow="true" EnableCollapseAll="true" EnableHover="true" ShowColumnMenu="true"
                 Toolbar="@(new List() { "Add", "Delete", "Update", "Cancel" })">
        < TreeGridEvents TValue="Node" OnToolbarClick="Toolbarclick" RowSelected="RowSelectHandler" OnActionComplete="ActionComplete" >
        < TreeGridSelectionSettings Type="Syncfusion.EJ2.Blazor.Grids.SelectionType.Single" Mode="Syncfusion.EJ2.Blazor.Grids.SelectionMode.Row">
< /TreeGridSelectionSettings>
        < TreeGridPageSettings PageSizeMode="PageSizeMode.Root" PageSize="50">
        < TreeGridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.EJ2.Blazor.TreeGrid.EditMode.Row">
< /TreeGridEditSettings>
        < TreeGridFilterSettings Type="Syncfusion.EJ2.Blazor.TreeGrid.FilterType.Menu">
        < TreeGridColumns>
            < TreeGridColumn Field="Code" HeaderText="Code" Width="20">
            < TreeGridColumn Field="Name" HeaderText="Name" Width="40">
            < TreeGridColumn Field="LegalName" HeaderText="Legal Name" Width="40">
            < TreeGridColumn Field="ExternalCode" HeaderText="Ext. Code" Width="20">
            < TreeGridColumn HeaderText=".." Width="15" Commands="commands" AllowReordering="false" AllowSorting="false" AllowResizing="false">
< /TreeGridColumn>
        < /TreeGridColumns>
    < /EjsTreeGrid>


MP Manivannan Padmanaban Syncfusion Team January 22, 2020 11:43 AM UTC

Hi Scott, 

Thanks for the update. 

Query : It seems the save and delete action events are not firing 

From the shared code example, we could see that you have not defined the primary key in the column definition which results the reported issue. In order to perform the CRUD operation in TreeGrid we need to define the primary key column. Kindly refer the below code example, 

<EjsTreeGrid DataSource="@TreeGridData" …………. > 
    ……………. 
 
    <TreeGridColumns> 
        <TreeGridColumn Field="TaskId" HeaderText="Task ID" IsPrimaryKey="true" Width="80" TextAlign="Syncfusion.EJ2.Blazor.Grids.TextAlign.Right"></TreeGridColumn> 
……………………. 
        <TreeGridColumn HeaderText="Manage Records" Width="150" Commands="@commands"></TreeGridColumn> 
    </TreeGridColumns> 
</EjsTreeGrid> 


 

For your convenience we have created the sample, refer the below link. 

Kindly get back to us, if you need further assistance. 

Regards, 
Manivannan Padmanaban. 



SP Scott Peal January 22, 2020 07:43 PM UTC

Thanks, that was the issue. Now it is working


SE Sathyanarayanamoorthy Eswararao Syncfusion Team January 23, 2020 07:09 AM UTC

Hi Scott, 

We are happy to hear that, your issue has been resolved. If you have any further queries, please get back to us. We will be happy to assist you. 

Regards, 
Sathyanarayanamoorthy 




MP Manivannan Padmanaban Syncfusion Team May 19, 2020 06:30 AM UTC

Hi Oscar, 

Greetings from Syncfusion Support. 

From V18.1.36-beta, we have name change in our component and syncfusion nuget package. There will also be changes to the name of the components in the help documentation. 

Kindly refer to the below link for release notes changes, 

Refer to the modified API link, 

Please get back to us, if you need further assistance. We will be happy to assist you. 

Regards, 
Manivannan Padmanaban 


Loader.
Live Chat Icon For mobile
Up arrow icon