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

Refreshing / selecting issue

Hello,

I've faced an issue with remote data and tree rendering. 

So the first problem I faced is that when you execute refresh after expanding row it refreshes the grid with additional params that were added while getting child data.

Sequence: 
1) Loaded treeGrid
2) Expanding one of the grid trees

3) Executing treeGrid.refresh() function. It executed with additional params that were passed for child data to render and now whole grid is just that row child data

What I could do and I did: removed params that stayed in query and then grid will be loaded as in the first picture where parent_ID is NULL. 

Query: But what if I want grid to be expanded as it was before the refresh ? 
So there are two ways that would work:
1) Refresh grid with parent_ID null and then expand elements to where the user was (This might be slow, cause we'll need all the child data to load again) and I couldn't manage to do it with treeGrid expand methods
or
2) Refresh only that data where user was. So this is basically how it works on expanding, gets data and adds to parent, but I would want this behaviour on refresh and leave user row selection as it was.


Additional notice:

When you filter treeGrid for exmaple with menu filter. Then expanding one of the rows, the data gets duplicated.

Sequence:
1) Filtered treeGrid with menu filter where value is "test". The result I got:


2) And when I'm expanding "test" row it gets data to child and to main grid, so it gets duplicated:



 

3 Replies

VN Vignesh Natarajan Syncfusion Team January 9, 2019 12:24 PM UTC

Hi Domantos, 

Thanks for contacting Syncfusion support. 

Query 1 : when you execute refresh after expanding row it refreshes the grid with additional params that were added while getting child data. 
 
We are able to reproduce the mentioned issue on our side. We have confirmed that the mentioned issue “Refreshing the Treegrid using refresh method after expanding a record binds the child data as datasource to the Treegrid” is a bug and have logged a defect report for the same. The fix for this issue will be included in the upcoming patch release on January 17th 2019. We appreciate your patience till then. 


Query 2: what if I want grid to be expanded as it was before the refresh ?  
 
We cannot store or detect which record is in expanded state after expanding a record. So, it is not feasible to maintain the expanded state of the records when the treegrid is refreshed.   
 
Query 3: When you filter TreeGrid for example with menu filter. Then expanding one of the rows, the data gets duplicated. 
 
Filtering feature is not supported for remote data in TreeGrid. When Filtering is enabled in the remote data we need to filter multiple levels of records from the dataSource with hierarchy relation maintained. If there are many levels, then searching and filtering the required records at all level will affect the performance of the control and so we have not provided support for remote data filtering. 

Regards, 
Vignesh Natarajan. 



DO Domantas January 11, 2019 01:05 PM UTC

Hello,

Alright, so I will approach my questions differently. I assume that what I want to do is possible with workaround. So now when you expand the row for the first time it sends the query with parentID and returns child data. And for example you collapse the expanded row and expand it again. When you're expanding it again it doesn't sent query cause data is already loaded with that parentID (I assume) and it just loads it from payload. So what if I would want to get child data from database at every single expand on the same row as it executes the very first time you expand. What is the condition that decides if it should call database or load from payload, can I remove data from there on collapse to manipulate data downloading again on expand?

Query: How to manipulate child data download every time on the same row expand 


VN Vignesh Natarajan Syncfusion Team January 14, 2019 10:53 AM UTC

Hi Domantas, 
 
Thanks for the update. 
 
Query: “How to manipulate child data download every time on the same row expand 
 
From your query we understand that you need to get the data from the server each time the child record are expanded. We suggest  you to achieve your requirement using Collapsed event and refresh() method of TreeGrid. Refer the below code example 
 
<ejs-treegrid #treegrid [dataSource]='data' idMapping='TaskID'  parentIdMapping='ParentItem' hasChildMapping='isParent' [treeColumnIndex]='1' allowPaging='true'  [pageSettings]='pageSetting' (collapsed)="onCollapse($event)"> 
        <e-columns> 
            <e-column field='TaskID' headerText='Task ID' width='120' textAlign='Right'></e-column> 
            <e-column field='TaskName' headerText='Task Name' width='150'></e-column> 
            <e-column field='StartDate' headerText='Start Date' width='120' format="yMd" textAlign='Right'></e-column> 
            <e-column field='EndDate' headerText='End Date' width='120' format="yMd" textAlign='Right'></e-column> 
            <e-column field='Duration' headerText='Duration' width='110' textAlign='Right'></e-column> 
            <e-column field='Progress' headerText='Progress' width='110'></e-column> 
            <e-column field='Priority' headerText='Priority' width='130'></e-column> 
        </e-columns> 
    </ejs-treegrid> 
 
 
 
onCollapse(e):void{ 
let trGrid = this.treegrid; 
trGrid.refresh(); 
    } 
 
 
 
Note: while collapsing the child data, calling the refresh method the dataSource. So everytime the parent record is expanded post will be send to server. 
 
For your convenience we have prepared a sample which can be referred from below link 
 
 
Refer our API documentation for your reference. 
 
 
 
Regards, 
Vignesh Natarajan 


Loader.
Live Chat Icon For mobile
Up arrow icon