Found bug in Treeview data type detection

Hello,

While trying to understand how/why the treeview component could determine if the data is hierarchical or flat, I came across these lines of code in file @syncfusion/ej2-vue-navigations/node_modules/@syncfusion/src/treeview/treeview.js (line 783 and down) for version 18.4.41.

    TreeView.prototype.getDataType = function (ds, mapper) {

        if (this.fields.dataSource instanceof DataManager && (this.fields.dataSource.adaptorName !== 'BlazorAdaptor')) {
            for (var i = 0; i < ds.length; i++) {
                if (this.isOffline) {
                    if ((typeof mapper.child === 'string') && isNOU(getValue(mapper.child, ds[i])) && !isNOU(getValue(mapper.parentID, ds[i]))) {
                        return 1;
                    }
                }
                else if ((typeof mapper.child === 'string') && isNOU(getValue(mapper.child, ds[i]))) {
                    return 1;
                }
            }
            return 2;
        }
        for (var i = 0, len = ds.length; i < len; i++) {
            if ((typeof mapper.child === 'string') && !isNOU(getValue(mapper.child, ds[i]))) {
                return 1; // was 2
            }
            if (!isNOU(getValue(mapper.parentID, ds[i])) || !isNOU(getValue(mapper.hasChildren, ds[i]))) {
                return 2; // was 1
            }
        }
        return 2; // was 1
    };



The old values are noted "was x" where I swapped in fact values 1 and 2. 

I discovered this because I wanted to load hierarchical data from database, but never managed - the ideal would be to be able to "force" the datatype using a new property. 

Could this be a bug ?

Thank you

Julien

PS: I use this version and not latest because it's the latest workable version on Nuxt



1 Reply

SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team December 30, 2021 12:18 PM UTC

Hi Julien, 
 
Greetings from Syncfusion support. 
 
We were unable to understand your exact requirement from your provided details. We suspect that you are expecting to load the remote hierarchical data with TreeView component. You can achieve this requirement by using the DataManager with data adaptors. Please, check out the following link. 
 
 
Query : the ideal would be to be able to "force" the datatype using a new property. 
 
Are you expecting load data which is not hierarchical or self-referential data? 
 
Please, share us more details regarding your requirement. 
 
  • Share us the issue details which you are facing when binding your remote data with TreeView.
  • If possible, share us the issue reproducing sample.
 
Regards, 
Shameer Ali Baig S. 
  


Loader.
Up arrow icon