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

Grid: Cannot group by a templated column

In an EjsGrid, is it possible to group by a templated column?

```
<GridColumn HeaderText="MyText" Width="200">
                            <Template>
                                @{
```

When I drop the column onto the drag bar, nothing happens. I notice that the GridGroupSettings Columns property expects GridColumn Field names but my templated GridColumn doesn't use a Field.

1 Reply

RS Renjith Singh Rajendran Syncfusion Team January 20, 2020 02:09 PM UTC

Hi Customer, 

Thanks for contacting Syncfusion support. 

We suggest you to set the Field property for the template column to Group Grid based on that template column. Please use the codes below, 

 
    <EjsGrid DataSource="@Orders" AllowGrouping="true" Height="315"> 
        <GridColumns> 
            <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" Width="120"></GridColumn> 
            <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150">    @*Set Field property for template column*@ 
                <Template> 
                    @{  
                        var data = context as Order; 
                        <div>@data.CustomerID</div> 
                    } 
                    </Template> 
            </GridColumn> 
       </GridColumns> 
    </EjsGrid> 
 
@code{ 
    ... 
    public class Order 
    { 
        public int? OrderID { get; set; } 
        public string CustomerID { get; set; } 
        public DateTime? OrderDate { get; set; } 
        public double? Freight { get; set; } 
    } 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Live Chat Icon For mobile
Up arrow icon