Hello,
I am currently working with a Kendo Grid in my ASP.NET MVC application, specifically with a foreign key column that retrieves its data from a separate data source. I have enabled filtering on this grid, and I would like to implement a "contains" filter for a foreign key column, specifically for the "Locations" column.
Here’s the relevant portion of my Kendo Grid configuration:
@(
Html.Kendo().Grid<FMS_Cloud_CoreMVC.ViewModels.EnergyAdmin>()
.Name("EAData")
.Filterable()
.Columns(
columns =>
{
columns.ForeignKey(p => p.CompLocID, ds => ds.Read("GetLocations", "EnergyAdmin"), "CompLocID", "CompLocString")
.Title("Locations").Width(300)
.Filterable(ftb => ftb.Cell(cell =>
cell.Operator("contains").SuggestionOperator(FilterType.Contains)));
columns.ForeignKey( p => p.Provider, ds => ds.Read( "GetEnergyProviders", "EnergyAdmin"), "DDLID", "ProviderName")
.Title("Provider").Width(150) ;
columns.Bound(p => p.NMI).Width(150);
columns.Bound(p => p.WWDeviceId).Width(150);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:730px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.EnergyAdminId))
.Create(update => update.Action("EditingInline_Create", "EnergyAdmin"))
.Read(read => read.Action("EditingInline_Read", "EnergyAdmin").Data("myCustomReadParam"))
.Update(update => update.Action("EditingInline_Update", "EnergyAdmin"))
.Destroy(update => update.Action("EditingInline_Destroy", "EnergyAdmin"))
)
)
While the "contains" filter works as expected with a simple text column, I would like to maintain the dropdown functionality for the foreign key column. Is there a way to achieve a "contains" filter on a foreign key column while still allowing users to select from the dropdown options?
I would greatly appreciate any guidance or examples you can provide.
Thank you in advance for your assistance!
I am currently working with a Kendo Grid in my ASP.NET MVC application, specifically with a foreign key column that retrieves its data from a separate data source. I have enabled filtering on this grid, and I would like to implement a "contains" filter for a foreign key column, specifically for the "Locations" column.
Here’s the relevant portion of my Kendo Grid configuration:
@(
Html.Kendo().Grid<FMS_Cloud_CoreMVC.ViewModels.EnergyAdmin>()
.Name("EAData")
.Filterable()
.Columns(
columns =>
{
columns.ForeignKey(p => p.CompLocID, ds => ds.Read("GetLocations", "EnergyAdmin"), "CompLocID", "CompLocString")
.Title("Locations").Width(300)
.Filterable(ftb => ftb.Cell(cell =>
cell.Operator("contains").SuggestionOperator(FilterType.Contains)));
columns.ForeignKey( p => p.Provider, ds => ds.Read( "GetEnergyProviders", "EnergyAdmin"), "DDLID", "ProviderName")
.Title("Provider").Width(150) ;
columns.Bound(p => p.NMI).Width(150);
columns.Bound(p => p.WWDeviceId).Width(150);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:730px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.EnergyAdminId))
.Create(update => update.Action("EditingInline_Create", "EnergyAdmin"))
.Read(read => read.Action("EditingInline_Read", "EnergyAdmin").Data("myCustomReadParam"))
.Update(update => update.Action("EditingInline_Update", "EnergyAdmin"))
.Destroy(update => update.Action("EditingInline_Destroy", "EnergyAdmin"))
)
)
While the "contains" filter works as expected with a simple text column, I would like to maintain the dropdown functionality for the foreign key column. Is there a way to achieve a "contains" filter on a foreign key column while still allowing users to select from the dropdown options?
I would greatly appreciate any guidance or examples you can provide.
Thank you in advance for your assistance!