Json viewer using TreeGrid in blazor wasm

Hi

In this link https://www.syncfusion.com/forums/167052/display-from-dynamic-json-data you explained how visualize a json using sfTreeGrid, 

Please can you share a sample code but for dynamic columns,  json can has multiple levels and variable properties

for blazor wasm.

Thanks in advance!


3 Replies

SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team June 2, 2023 05:05 AM UTC

Hi Jose,


It is possible to dynamically build and customize each of the TreeGrid column using the type of the model. Please refer to the following code snippet.


<SfTreeGrid>

    <TreeGridColumns>

        @foreach (var prop in columnData)

        {

            <TreeGridColumn Field="@prop.Field" HeaderText="@prop.HeaderText">

            </TreeGridColumn>

        }

    </TreeGridColumns>

</SfTreeGrid>

 

@code {

 

    . . . . .

 

    public List<TreeGridColumn> columnData = new List<TreeGridColumn>()

    {

        new TreeGridColumn(){ Field= "id", HeaderText="ID"},

        new TreeGridColumn(){ Field = "name", HeaderText = "Name"},

        new TreeGridColumn(){ Field = "make", HeaderText = "Make"},

    };

 

}


Please refer to the Grid’s documentation for reference : https://blazor.syncfusion.com/documentation/datagrid/columns#dynamic-column-building


If the above solution does not meet your requirement, kindly share us more details or kindly share us the simple issue replicating sample.


Regards,

Shek Mohammed Asiq



JL jose luis barajas June 16, 2023 07:17 PM UTC

Thanks!!



SG Suganya Gopinath Syncfusion Team June 19, 2023 06:21 AM UTC

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.



Loader.
Up arrow icon