Changing columns on TreeGrid after initialize

Hi Syncfusion,

In a different thread I noted that on versions 18.2.0.47 and 18.2.0.48, the Columns binding on the TreeGrid control broke and we started getting exceptions:

System.InvalidOperationException: The converter specified on 'Syncfusion.Blazor.TreeGrid.TreeGridColumn.EditTemplate' does not derive from JsonConverter or have a public parameterless constructor.

Code would look like below:
<SfTreeGrid @ref="TreeGrid" DataSource="@TreeGridRows"
            IdMapping="Id"
            ParentIdMapping="ParentId"
            TreeColumnIndex="0" AllowSorting="true" AllowPaging="true" Columns="@TreeColumns">
</SfTreeGrid>

and to overcome this issue we had to remove the columns binding and replace it with a foreach like below:

<SfTreeGrid @ref="TreeGrid" DataSource="@TreeGridRows"
            IdMapping="Id"
            ParentIdMapping="ParentId"
            TreeColumnIndex="0" AllowSorting="true" AllowPaging="true">
    <TreeGridColumns>
        @foreach (var treeGridColumn in @TreeColumns)
        {
            <TreeGridColumn Field="@treeGridColumn.Field" HeaderText="@treeGridColumn.HeaderText" Width="@treeGridColumn.Width"></TreeGridColumn>
        }
    </TreeGridColumns>
</SfTreeGrid>

the above workaround got the TreeGrid to display the data, and now the columns were showing OK, but we are currently experiencing another issue where we want to change our Columns (replace with new ones alongside a new source).

Since the TreeGrid we are building is of dynamic nature and can have different columns, and can also have an updated data source, we need this to work.

our DataSource is a List of ExpandoObject below:

public List<ExpandoObject> TreeGridRows { get; set; } = new List<ExpandoObject>();

and this is the columns property:

public List<TreeGridColumn> TreeColumns = new List<TreeGridColumn>();

We have tried to use the newly introduced Refresh method:

TreeGrid.Refresh();
StateHasChanged();

but that doesn't seem to work. After we change the columns, we don't see the newly added columns in the TreeGrid.

Can you please let us know if this is a known bug, and if not how to workaround it?

thanks



2 Replies 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 19, 2020 02:14 PM UTC

Hi Basil, 

Thanks for contacting Syncfusion Support. 

We are able to replicate the problem at our end. We will validate and provide you further details by 20th August 2020. 

Regards, 
Farveen sulthana T 



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 20, 2020 03:53 PM UTC

Hi Basil, 

We appreciate your patience. 

Query#:- After we change the columns, we don't see the newly added columns in the TreeGrid. 
 
While analyzing, we have confirmed this reported problem “Dynamically added columns not refreshed while using expandobject” as bug at our end. The fix for this problem will be included in our upcoming NuGet release which will be expected to roll out at 26th August 2020. 

You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this Feedback link.      

Please get back to us if you have any queries. 

Regards, 
Farveen sulthana T 
 


Marked as answer
Loader.
Up arrow icon