TreeGrid not refreshing after changes in the DataSource

I have this TreeGrid structure, which I bind to a List<TreeItem> is this way:

<EjsTreeGrid @ref="TreeDetall" AllowExcelExport="true" DataSource="@TreeData" IdMapping="Id" Width="100%" ParentIdMapping="ParentId"
                         AllowSelection="true" AllowSorting="true" TreeColumnIndex="0" EnableAltRow="true" EnableHover="true" TValue="TreeItem">
                <TreeGridColumns>
                    <TreeGridColumn Field="Ordre" HeaderText="#" Width="110" HeaderTextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:110px; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">@((context as TreeItem).Ordre)</div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="Descripcio" HeaderText="@StringLocalizer.GetText(ci, "DESCRIPCIÓ")" Width="240" HeaderTextAlign="TextAlign.Left">
                        <Template>
                            <div style="width:240px; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((MarkupString)(context as TreeItem).Descripcio)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="Quantitat" HeaderText="@StringLocalizer.GetText(ci, "QUANTITAT")" Width="100" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:100px; text-align:center; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((context as TreeItem).Quantitat)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="Unitat" HeaderText="@StringLocalizer.GetText(ci, "UT")" Width="60" HeaderTextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:60px; text-align:center; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((context as TreeItem).Unitat)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="Preu" HeaderText="@StringLocalizer.GetText(ci, "PREU")" Width="90" HeaderTextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:90px; text-align:center; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((context as TreeItem).Preu)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="Import" HeaderText="@StringLocalizer.GetText(ci, "IMPORT")" Width="90" HeaderTextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:90px; text-align:center; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((context as TreeItem).Import)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn Field="K" HeaderText="K" Width="60" HeaderTextAlign="TextAlign.Center">
                        <Template>
                            <div style="width:60px; text-align:center; @((context as TreeItem).IsCapitol ? "font-weight:bold;":"")">
                                @((context as TreeItem).K)
                            </div>
                        </Template>
                    </TreeGridColumn>
                    <TreeGridColumn HeaderText="" Width="42">
                        <Template>
                            @{
                                var treeItem = (context as TreeItem);
                                var item = Pressupost.Detall.First(i => i.Id == treeItem.Id);
                                bool isCapitol = (item.GetType() == typeof(CapitolEntity));
                            }
                            <button class="btn btn-sm btn-outline-warning" @onclick="@(e => (isCapitol ? ModalAfegeixCapitol((CapitolEntity)item) : ModalAfegeixPartida((PartidaEntity)item)))">
                                <i class="fas fa-edit"></i>
                            </button>
                        </Template>
                    </TreeGridColumn>
                </TreeGridColumns>
            </EjsTreeGrid>

The code behind goes like this, where TreeData is rebuilt on any change, but the grid is not refreshed with the new items even if I call the Refresh method.


        protected List<TreeItem> TreeData { get; set; }
        protected EjsTreeGrid<TreeItem> TreeDetall;
        protected class TreeItem
        {
            public long Id { get; set; }
            public string Ordre { get; set; }
            public string Descripcio { get; set; }
            public string Quantitat { get; set; }
            public string Unitat { get; set; }
            public string Preu { get; set; }
            public string Import { get; set; }
            public string K { get; set; }
            public bool CustomK { get; set; }
            public long? ParentId { get; set; }
            public bool IsCapitol { get; set; }
        }

        protected void PopulateTreeData()
        {
            if (TreeData != null)
                TreeData.Clear();
            else
                TreeData = new List<TreeItem>();

            foreach (ItemEntity item in Pressupost.Detall)
            {
                if (item.GetType() == typeof(CapitolEntity))
                {
                    CapitolEntity capitol = (CapitolEntity)item;
                    TreeData.Add(new TreeItem(capitol));
                }
                else
                {
                    PartidaEntity partida = (PartidaEntity)item;
                    TreeData.Add(new TreeItem(partida));
                }
            }
        }

The process would be:
- Make changes in the main structure
- Call PopulateTreeData
- Call TreeDetall.Refresh(); and StateHasChanged();

But nothing occurs in the grid, same items, same values. 
Also, if an Item is deleted, this line crashes:
var item = Pressupost.Detall.First(i => i.Id == treeItem.Id);
Meaning that the TreeGrid is keeping an outdated version of the datasource...

Any idea of what could be happening?

Thanks!

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team February 13, 2020 01:35 PM UTC

Hi Ton, 
 
Greetings from Syncfusion support. 
 
We have validated the reported issue “DataSource changes is not updated in TreeGrid” at our end and we have confirmed it is a breaking issue from our side. We have logged a defect report for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including in our upcoming patch release on February 19, 2020. Until then we appreciate your patience. 
  
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 
  

Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 
 



DD David Dumitru March 24, 2020 07:32 PM UTC

Hi,

Is this bug fixed? 'cause I'm experiencing it in the latest version as well. (18.1.0.36-beta)


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 25, 2020 12:54 PM UTC

Hi David,   

Sorry for the inconvenience caused.   

Query:- Is this bug fixed? 'cause I'm experiencing it in the latest version as well. (18.1.0.36-beta)   
    
The reported issue has been fixed internally and due to some breaking changes it is not included in our 18.1.0.36- beta release. We have planned to include the issue in our 2020 Volume 1 main release which is expected to  roll out in the first week of April.   

Regards,   
Farveen Sulthana T   



DD David Dumitru March 25, 2020 01:08 PM UTC

I see, thanks for the info. We will patiently wait then :D 

Take care


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 26, 2020 04:24 AM UTC

Hi David,    

Thanks for your update. We will let know release has been roll out. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon