I have table in database which contains events of a system and these events have severity code and event code. These codes have to be localized, it means the text for the severity and event codes should be taken from resource files.
Here is how we construct data for the grid:
public
ActionResult GetEvents([DataSourceRequest] DataSourceRequest request)
{
IQueryable<SystemEventGridModel> data = SystemEvent.GetSystemEventFromDatabase().Select(systemEvent =>
new
SystemEventGridModel
{
Id = systemEvent.Id,
EventCode = systemEvent.EventCode,
SeverityCode = systemEvent.SeverityCode,
Date = systemEvent.Date,
Node = systemEvent.Node,
IsActive = systemEvent.IsActive
});
DataSourceResult dataSourceResult = data.ToDataSourceResult(request);
foreach
(SystemEventGridModel gridModel
in
dataSourceResult.Data)
{
gridModel.EventText = Language.ResourceManager.GetString($
"EventText{gridModel.EventCode}"
);
gridModel.SeverityText = Language.ResourceManager.GetString($
"SeverityText{gridModel.SeverityCode}"
);
}
return
Json(dataSourceResult);
}
Then in the grid we show the localized text but not the codes:
@(Html.Kendo().Grid<
SystemEventGridModel
>()
.Name("SystemEventGrid")
.Columns(columns =>
{
columns.Bound(x => x.Node).Title(Language.SystemEventGridModelTitleNode);
columns.Bound(x => x.SeverityCode).Title(Language.SystemEventGridModelTitleSeverityText).ClientTemplate("#=SeverityText#").Filterable(x => x.Multi(true).CheckAll(false).ItemTemplate("function(e){return columnFirtalableItemTemplate('SeverityCode', 'SeverityText')}"));
columns.Bound(x => x.EventCode).Title(Language.SystemEventGridModelTitleEventText).ClientTemplate("#=EventText#");
columns.Bound(x => x.Date).Title(Language.SystemEventGridModelTitleDate);
columns.Bound(x => x.IsActive).Title(Language.SystemEventGridModelTitleIsActive);
})
.DataSource(binding => binding.Ajax().Read("GetEvents", "Home", null))
.Sortable()
.Filterable()
.Pageable(x => x.Refresh(true)))
The problem is that we can't use the standard filtering for the columns (e.g. EventText) which do not existing in database and are taken from different places:
Is there a way to apply the filtering for the text and search by code from database?
P.S. I attached only the source files (models, views and controllers) for the example code.