Use SfGrid without a DataSource?

Is it possible to achieve something like this with SfGrid?


```

<table class="table table-striped table-bordered" >

    <thead>

    <tr>

        <th>Year</th>

        <th>Total</th>

        @for (int month = 1; month < 13; month++)

        {

            var dateTime = new DateTime(2000, month, 1);

            <th>@dateTime.ToString("MMM")</th>

        }

    </tr>

    </thead>

    <tbody>

    @foreach (var item in _dataShownOnChart)

    {

        <tr>

            <td style="white-space: nowrap;">@item.CrewType</td>

            <td style="text-align: right;">@item.MonthAndHours.Sum(x=>x.Hours).ToString("N0")</td>

            @for (var index = 0; index < 12; index++)

            {

                if (index < item.MonthAndHours.Count)

                {

                    var month = item.MonthAndHours[index];

                    <td style="text-align: right;">@month.Hours.ToString("N0")</td>

                }

                else

                {

                    <td></td>

                }

            }

        </tr>

    }

    </tbody>

</table>

```



3 Replies

JA Jason May 13, 2022 05:19 AM UTC

Also, I can't edit my first post because the content is converted to html and rendered as such. That seems like a bug in the forum. 



RS Renjith Singh Rajendran Syncfusion Team May 16, 2022 09:53 AM UTC

Hi Jason,


Greetings from Syncfusion support.


We have inbuilt support for rendering customized column cells in grid using Column Template feature. Please refer the below documentation for more details.

References :

https://blazor.syncfusion.com/documentation/datagrid/column-template#using-conditions-inside-template

https://blazor.syncfusion.com/documentation/datagrid/columns#dynamic-column-building


Please refer the above documentations and check this from your side. If you are facing any difficulties, then kindly get back to us with the details to proceed further.


And also we have Row Template support to render customized rows in Grid. Please refer the below documentation for more details.

https://blazor.syncfusion.com/documentation/datagrid/row-template

https://blazor.syncfusion.com/documentation/datagrid/row-template#limitations


Query : I can't edit my first post because the content is converted to html and rendered as such. That seems like a bug in the forum.

We have logged the bug report for this issue, we will fix this issue and this will be refreshed on or before 26th May, 2022.


Regards,

Renjith R



RS Renjith Singh Rajendran Syncfusion Team May 26, 2022 11:08 AM UTC

Hi Jason,

Query : I can't edit my first post because the content is converted to html and rendered as such. That seems like a bug in the forum.

We have branched a new ticket under your account for this query. Please follow up on that ticket for future updates on this.

Regards,

Renjith R


Loader.
Up arrow icon