TreeGrid Searching not working

Hi,
I have successfully implemented skip and take method using data manager and url adaptors in the Treegrid. but when I want to search the TreeGrid stays on the loading page after perform the search opertion in the backend.


Here is my code:

<ejs-treegrid id="TreeGrid"

              toolbar="@(new List<object>() { "Search", "Add","Edit","Delete", "Update", "Cancel",

             new {

                text = "Open",

                tooltipText = "Open workflow to uptate it",

                prefixIcon = "e-open",

                id = "Open"

             },

             new {

                text = "AddFolder",

                tooltipText = "Add a new folder in the current parent folder",

                prefixIcon = "e-open",

                id = "AddFolder"

             },

             new {

                text = "AddFlow",

                tooltipText = "Add a new folder in the current parent folder",

                prefixIcon = "e-open",

                id = "AddFlow"

             },

             new {

                text = "Publish",

                tooltipText = "Add a new folder in the current parent folder",

                prefixIcon = "e-open",

                id = "Publish"

             },

              new {

                text = "Unpublish",

                tooltipText = "Add a new folder in the current parent folder",

                prefixIcon = "e-open",

                id = "Unpublish"

             }})"

             idMapping="id"

             treeColumnIndex="1"

             hasChildMapping="isFolder"

             parentIdMapping="parentId"

             allowPaging="true"

             allowRowDragAndDrop="true"

             loadChildOnDemand="true"

             toolbarClick="toolbarClick"

             actionComplete="actionComplete"

             recordDoubleClick="recordDoubleClick"

             rowSelected="rowSelectionChanged"

             rowDeselected="rowDeselectionChanged"

             dataBound="rowDeselectionChanged"

             rowDrop="rowDrop"

             load="onLoad"

              >

    <e-data-manager url="/admin/flowz/definitions?handler=DataSource" adaptor="UrlAdaptor" crossDomain="true"></e-data-manager>


    <e-treegrid-searchSettings fields="@(new string[] { "WorkflowName" })" operator="contains" hierarchyMode="Child" ignoreCase="true"></e-treegrid-searchSettings>


    <e-treegrid-selectionsettings type="Single"></e-treegrid-selectionsettings>


    <e-treegrid-editSettings allowAdding="true" allowDeleting="true" allowEditing="false" mode="Row" newRowPosition="Child"></e-treegrid-editSettings>


    <e-treegrid-columns>

        <e-treegrid-column field="id" headerText="Id" textAlign="Right" width="90" isPrimaryKey="true" visible="false"></e-treegrid-column>

        <e-treegrid-column field="folderName" headerText="FolderName" width="180"></e-treegrid-column>

        <e-treegrid-column field="workflowName" headerText="WorkflowName" width="180" allowediting="false"></e-treegrid-column>

        <e-treegrid-column field="version" headerText="Version" width="180" allowediting="false"></e-treegrid-column>

        <e-treegrid-column field="isPublished" headerText="IsPublished" width="180" allowediting="false"></e-treegrid-column>

        <e-treegrid-column field="lastExecutedAt" headerText="LastExecutedAt" width="180" allowediting="false"></e-treegrid-column>

        <e-treegrid-column field="protected" headerText="Protected" width="180" editType="booleanedit" displayAsCheckBox="true"></e-treegrid-column>

    </e-treegrid-columns>


</ejs-treegrid>


        public JsonResult OnPostDataSource([FromBody] DataManagerRequest dm)

        {

            var treeItems = _context.TreeViewDisplays.ToList();

            IEnumerable DataSource = treeItems;

            DataOperations operation = new DataOperations();


            if (dm.Search != null && dm.Search.Count > 0) //Search

            {

                DataSource = operation.PerformSearching(DataSource, dm.Search);

                //var result = treeItems.FindAll(i => i.WorkflowName.Contains(dm.Search[0].Key));

                //DataSource = result.ToList();

            }


            int count = DataSource.Cast<TreeViewDisplay>().Count();


            //if (dm.Skip != 0)

            //{

            // DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging

            //}


            //if (dm.Take != 0)

            //{

            // DataSource = operation.PerformTake(DataSource, dm.Take);

            //}


            return dm.RequiresCounts ? new JsonResult(new { result = DataSource, count = count }) : new JsonResult(DataSource);

        }


I am using the  "Syncfusion.EJ2.AspNet.Core" Version: 20.3.04.7 NuGet package.


Thanks!

 




1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team September 30, 2022 03:09 PM UTC

Hi Alexander,


We have checked your query and while using loadChildOnDemand property, we need to handle the DataOperations for child records at server end.

https://ej2.syncfusion.com/aspnetcore/documentation/tree-grid/data-binding-core?cs-save-lang=1&cs-lang=csharp#loadchildondemand


So we suggest to handle PerformSearching for child records using CollectChildRecords method at server end in order to perform Search for child records.


Please get back to us if you need any further assistance on it.


Regards,

Farveen sulthana T


Loader.
Up arrow icon