Filtering columns that aren't bound to a Field

Hello,

I am trying to use an SfGrid to view results that are coming back from a web service and and deserialized to a generic record structure:
public class Record
{
public string Id { get; set; }
public Dictionary<string, object> Values { get; set; } = new Dictionary<string, object>();
}
I know the schema information about the data coming back, and that info and a custom adaptor, I'm able to view the data just fine:
<SfGrid @ref="@Grid" TValue="Record" AllowPaging="true" ShowColumnChooser="true" AllowReordering="true" AllowSorting="true" AllowResizing="true" AllowFiltering="true" Toolbar="@_toolbarItems">
<GridFilterSettings ShowFilterBarStatus="true" Mode="FilterBarMode.Immediate" Type="FilterType.FilterBar"></GridFilterSettings>
<SfDataManager Adaptor="Adaptors.CustomAdaptor">
<TableAdaptor TableId="@TableId"></TableAdaptor>
</SfDataManager>
<GridColumns>
@foreach (var field in Table.Fields)
{
<GridColumn Type="@field.AsColumnType()" HeaderText="@field.Name" TextAlign="TextAlign.Left" Width="130" AllowFiltering="true">
<Template>
@{
var record = context as Record;
<div>@(record?.Get[field.Id] ?? string.Empty)</div>
}
</Template>
</GridColumn>
}
</GridColumns>
</SfGrid>
The problem I'm encountering is that there is no way for me to filter the results.  Through experimentation, it appears the only way for filtering to work is is a GridColumn is bound to a Field.  That makes sense, as you'd need to know the Id of the field to filter for; however when you're using a Template to choose the value to display, there appears to be no way to filter.  Am I missing something?  Is there a way to specify a ColumnId for filtering without having to bind to a Field?
Thanks,
Jon...



1 Reply

JP Jeevakanth Palaniappan Syncfusion Team February 9, 2021 06:24 AM UTC

Hi Jon, 

Greetings from Syncfusion support. 

We have checked your query and we would like to inform you that the column template feature is only to customize the element/content of the column. So to do data operation like filtering, sorting etc.. it must to specify the corresponding field to the grid column. Based on the field only, these operations will be handled internally. 

Below is the documentation for filtering and column template features. 


Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 
 


Loader.
Up arrow icon