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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TreeView search from schedulers drag and drop

Thread ID:

Created:

Updated:

Platform:

Replies:

148963 Nov 9,2019 12:55 PM UTC Nov 22,2019 11:51 AM UTC ASP.NET Core - EJ 2 18
loading
Tags: TreeView
Cris
Asked On November 9, 2019 12:55 PM UTC

Hi I have this example 


and wanted to add a search from the TreeView because of a large record (5k) . Does anyone know how to do that? Thanks I appreciate your help.

Cris
Replied On November 9, 2019 03:52 PM UTC

Also if I changed the code to remote data, there is error on the script

    var dataClients = new DataManager()
    {
        Url = "SchedulersAdd/LoadClients",
        Adaptor = "UrlAdaptor",
        CrossDomain = true
    };

------------

                    <ejs-treeview id="tree" allowDragAndDrop="true" nodeDragStop="onTreeDragStop" nodeDragging="onItemDrag" nodeTemplate="#treeTemplate" cssClass="treeview-external-drag">
                        <e-treeview-fields dataSource="dataClients" id="Id" text="ClientName"></e-treeview-fields>
                    </ejs-treeview>


--------------------

the onTreeDragStop function breaks

 function onTreeDragStop(event) {
            var treeElement = ej.base.closest(event.target, '.e-treeview');
            var scheduleObj = document.querySelector(".e-schedule").ej2_instances[0];
            var classElement = scheduleObj.element.querySelector('.e-device-hover');
            if (classElement) {
                classElement.classList.remove('e-device-hover');
            }
            if (!treeElement) {
                event.cancel = true;
                var scheduleElement = ej.base.closest(event.target, '.e-content-wrap');
                if (scheduleElement) {
                    var treeviewData = this.fields.dataSource;

                    if (event.target.classList.contains('e-work-cells')) {
                        var filteredData = treeviewData.filter(function (item) { return item.Id === parseInt(event.draggedNodeData.id, 10); });
..............

error

Uncaught TypeError: treeviewData.filter is not a function at onTreeDragStop 

Keerthana Rajendran [Syncfusion]
Replied On November 11, 2019 11:25 AM UTC

Hi Cris, 
  
Good day to you. 
  
We have checked your provided code block and reported problem. If you want to get the date source of Tree View component while using remote data source, you can use the getTreeData method , because we have stored the corresponding remote data url and fields details in this.fields.dataSource variable, so we were unable to get the corresponding remote data json details bound to the control. 
 
Query:  add a search from the TreeView because of a large record  
 
We have validated the provided data source and query at our end. Currently, we have filtering support only for the flat data source. Since the filtering of the remote data source will be more complex, can you please check and provide a flat data instead of remote data if possible? 
  
  
If your requirement does not satisfy, please let us know the following details 
  
a. Whether you want to filter and showcase the searched text alone or if you want to showcase with its corresponding parent data as in the above example 
  
Kindly get back to us with the above-asked details if your requirement is not satisfied with the flat data source. It would be more helpful to assist you further. 
 
Regards, 
Keerthana. 


Cris
Replied On November 11, 2019 01:06 PM UTC

I get it I will use getTreeData to get the data but how do I change the dataSource? Do you have a rewrite for the code? Thanks so much i appreciate your help

function changeDataSource(data) {
    listTreeObj.fields = {
        dataSource: data, id: 'id', text: 'name', parentID: 'pid', hasChildren: 'hasChild'
    }
}

Cris
Replied On November 11, 2019 01:52 PM UTC

how do you suggest I do this? I have a very large data of clients that I want to load in the treeView and add search? Thanks I appreciate your help.

Cris
Replied On November 12, 2019 01:09 PM UTC

I changed to local data, it still doesnt work.  ReferenceError: treeDataSource is not defined

                    <ejs-maskedtextbox id="inputBox" placeholder="Enter client to search"></ejs-maskedtextbox>
                    <ejs-treeview id="tree" allowDragAndDrop="true" nodeDragStop="onTreeDragStop" nodeDragging="onItemDrag" nodeTemplate="#treeTemplate" cssClass="treeview-external-drag">
                        <e-treeview-fields dataSource="ViewBag.treeDataSource" id="Id" text="ClientName"></e-treeview-fields>
                    </ejs-treeview>

-----------------

        var listTreeObj = new ej.navigations.TreeView({
             fields: { dataSource: treeDataSource, id: 'id', parentID: 'pid', text: 'clientName', hasChildren: 'hasChild', expanded: "expanded" },
        });
        listTreeObj.appendTo('#tree');

Keerthana Rajendran [Syncfusion]
Replied On November 13, 2019 02:18 PM UTC

  
Hi Cris, 
  
Good day to you. 
 
We have checked your query that TreeView search functionality was not working with local data. But we didn’t face any issues while using this functionality in TreeView. Kindly refer to the below KB documentation link for filtering with local data. 
  
  
We checked that treeDataSource is not defined error. We suspect that treeDataSource was not returned properly from the server side. So, could you please ensure it from your end. 
  
If you want to use search functionality in large data, we suggest you make an AJAX call and pass the characters entered in the input to server-side through input events (input, keyup, keydown). You can filter the dataSource based on these characters in server side and assign them back in client side through fields property of TreeView component. 
 
Please refer the below help document to update data source for each search operations data's in TreeView component. 
  
  
Please get back to us if you face any difficulties with this AJAX call approach. 
  
Regards, 
Keerthana. 


Cris
Replied On November 13, 2019 02:37 PM UTC

Hi I have this code below, I am also doing a drag and drop to a scheduler (which is also not working). Could you tell me what I am doing wrong with the search

<input id="inputBox" type="text">
<div id="tree"></div>

----------
<script>

 ej.base.enableRipple(true);

        var dataClients = new ej.data.DataManager({
            url: 'SchedulersAdd/LoadClients',
            adaptor: new ej.data.UrlAdaptor(),
            crossDomain: true,
        });

        var listTreeObj = new ej.navigations.TreeView({
            fields: { dataSource: dataClients, id: 'Id', text: 'ClientName', child: 'child', selected: 'isSelected' },
            allowDragAndDrop: true,
            addClass: "treeview-external-drag",
            nodeDragStop: "onTreeDragStop",
            nodeDragging: "onItemDrag",
            nodeTemplate: "#treeTemplate"
        });
        listTreeObj.appendTo('#tree');

        // Render the MaskedTextBox input element
        var mask = new ej.inputs.MaskedTextBox({
            placeholder: "Enter the tree node to search",
            change: searchNodes
        });
        mask.appendTo('#inputBox');

        // Change the dataSource for TreeView
        function changeDataSource() {
            listTreeObj.fields = { dataSource: dataClients, id: 'Id', text: 'ClientName', child: 'child', selected: 'isSelected' };
            listTreeObj.allowDragAndDrop = true;
        }
        // Filtering the tree nodes
        function searchNodes(args) {
            //var listTreeObj = ej.base.getComponent(document.querySelector('#tree'), 'treeview');
            var _text = mask.element.value;
            var predicats = [], _array = [], _filter = [];
             if (_text == "") {
                //changeDataSource(listTreeObj.getTreeData());
                changeDataSource();
            }
            else {

                var predicate = new ej.data.Predicate('name', 'contains', _text, true);
                var filteredList = new ej.data.DataManager(dataClients).executeLocal(new ej.data.Query().where(predicate));

                for (var j = 0; j < filteredList.length; j++) {
                    _filter.push(filteredList[j]["id"]);
                    var filters = getFilterItems(filteredList[j], dataClients);
                    for (var i = 0; i < filters.length; i++) {
                        if (_array.indexOf(filters[i]) == -1 && filters[i] != null) {
                            _array.push(filters[i]);
                            predicats.push(new ej.data.Predicate('id', 'equal', filters[i], false));
                        }
                    }
                }
                if (predicats.length == 0) {
                    changeDataSource([]);
                } else {
                    var query = new ej.data.Query().where(new ej.data.Predicate.or(predicats));
                    var newList = new ej.data.DataManager(dataClients).executeLocal(query);
                    changeDataSource(newList);
                    setTimeout(function () {
                        listTreeObj.expandAll();
                    }, 100);
                }
            }
        }
        // Find the parent nodes for corresponding childs
        function getFilterItems(fList, list) {
            var nodes = [];
            nodes.push(fList["id"]);
            var query2 = new ej.data.Query().where('id', 'equal', fList["pid"], false);
            var fList1 = new ej.data.DataManager(dataClients).executeLocal(query2);
            if (fList1.length != 0) {
                var pNode = getFilterItems(fList1[0], list);
                for (var i = 0; i < pNode.length; i++) {
                    if (nodes.indexOf(pNode[i]) == -1 && pNode[i] != null)
                        nodes.push(pNode[i]);
                }
                return nodes;
            }
            return nodes;
        }
</script>

Cris
Replied On November 13, 2019 02:57 PM UTC

If you want to use search functionality in large data, we suggest you make an AJAX call and pass the characters entered in the input to server-side through input events (input, keyup, keydown). You can filter the dataSource based on these characters in server side and assign them back in client side through fields property of TreeView component.

--- Isnt this a slower solution? I was planning on dumping all 5k clients on the treeView and searching on it with a local dataSource(as soon as you help with this thing working). Also does the Javascript allowdraganddrop doesnt work in my example. When I click and drag my mouse pointer turns to a stop icon (red circle with a slash).

Cris
Replied On November 14, 2019 01:38 PM UTC

Do you have a code that could let me do this? Am getting frustrated and I cant get the code right, Thanks so much for your help I really appreciate it.

Muthukrishnan Kandasamy [Syncfusion]
Replied On November 14, 2019 02:41 PM UTC

Hi Cris, 
 
Thanks for your patience. 
 
In our Treeview component we have provided filtering support for flat data source only. If you are using hierarchical or remote data source in Tree View component you need to rewrite the logic for filtering support. 
 
You have mentioned drag and drop was not working in TreeView component on your project. If you are using remote data or hierarchical data, you are unable to get the data source using tree view fields property, so you need to use getTreeData method to get the TreeView data are do the necessary options in scheduler. We have also attached the sample for your reference. Please find it below. 
 
 
We have prepared the sample for filtering support in TreeView component using Remote dataSource(“flat data”). Could you please check the sample and video? 
  
Sample link: 
 
 
Video link: 
 
 
Please let us know, if you require any further assistance on this. 
 
Regards, 
Muthukrishnan K 


Cris
Replied On November 15, 2019 12:01 PM UTC

Thanks it finally worked. I just noticed something. Right now am loading all the clients from the treeview (5k). But scheduler operation is slow (clicking the schedules, dragging the clients etc.). But when I search for fewer clients the scheduler and drag and drop is much faster. What do you suggest i do to make it faster? Does treeview has some kind of lazy loading? Thanks I appreciate your help.

Keerthana Rajendran [Syncfusion]
Replied On November 18, 2019 09:33 AM UTC

Hi Cris, 
 
Good day to you. 
 
Query: But scheduler operation is slow (clicking the schedules, dragging the clients etc.). But when I search for fewer clients the scheduler and drag and drop is much faster. What do you suggest i do to make it faster? 
 
We have validated the reported scenario in the below sample, there is no time delay while performing external and internal drag & drop of the Scheduler. It takes a reasonable time. So kindly share the replication steps or replicate the issue in below sample to serve you better.  
 
 
Query: Does treeview has some kind of lazy loading 
 
By default, TreeView has loadOnDemand property set to true which will load first level nodes initially. Child nodes will be loaded when the corresponding parent node is expanded. Please refer to the following UG link 
 
 
Regards, 
Keerthana.  


Cris
Replied On November 18, 2019 01:11 PM UTC

Try loading 5,000 patients.

Keerthana Rajendran [Syncfusion]
Replied On November 19, 2019 06:48 AM UTC

Hi Cris, 
 
We have validated the reported scenario and the Scheduler component is getting slow as reported. We have already logged this feature as performance improvement, and it will be implemented in any one of our upcoming release. We would appreciate your valuable patience until then. You can track the status through the below feedback link 
 
Regards, 
Keerthana. 


Cris
Replied On November 19, 2019 10:07 PM UTC

Is there any workaround regarding the issue of loading? Can I have a button that actually starts the loading and another button which unloads it if I dont need it? Thanks so much I appreciate your help.

Vinitha Devi Murugan [Syncfusion]
Replied On November 20, 2019 11:04 AM UTC

Hi Cris, 
 
Thanks for your update. 
 
Q1: Could you please share below details with us to serve you better.  
  1. How much number of resources and appointments loaded in your scheduler.
  2. How much number of appointment loaded in current view.
  3. Which browser are you using?
  4. Whether you are using remote data or local data.
  5. Did you used template for events and resources?
  6. Did you used virtualScrolling option of the scheduler?
Q2: We prepared the sample to load and unload the datasource of the scheduler based on button click and same can be available in below link. 
 
 
Regards, 
M.Vinitha devi  


Cris
Replied On November 21, 2019 11:21 AM UTC

  1. How much number of resources and appointments loaded in your scheduler.
  2. How much number of appointment loaded in current view.
  3. Which browser are you using?
  4. Whether you are using remote data or local data.
  5. Did you used template for events and resources?
  6. Did you used virtualScrolling option of the scheduler?

ANSWERS

1. There is not a lot, but I have a lot of clients (5k) loaded in the Treeview and its slowing everything down.
2. same answer as 1
3. I am using Chrome
4. You have given me the code to this.
5. Yes I do.
6. No I dont, its not the scheduler that slowing it down, its the clients(5k) on the treeview.

I saw your example on the link you gave, what I need is the load and unload from the Treeview for the clients (5k). Thanks so much I appreciate it.

Keerthana Rajendran [Syncfusion]
Replied On November 22, 2019 11:51 AM UTC

Hi Cris, 
 
We have created a support incident under your Direct-trac account for TreeView query. Please follow up with that incident for further details. 
 
Regards, 
Keerthana.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon