This is my grid:
@(Html.Kendo().Grid<Project>()
.Name("ProjectsGrid")
.Columns(columns =>
{
columns.Bound(p => p.ProjectName)
.ClientTemplate("<a href=/Directory/project/${Id} target=_blank>${ProjectName}</a>")
.Width(180);
columns.Bound(p => p.ProjectManager).Width(230)
.ClientTemplate("#=data.ProjectManager?.Name#")
.EditorTemplateName("WorkingEmployee")
.Sortable(s => s.Compare("(a, b) => compareManager(a, b)"));
columns.Bound(p => p.IsActive)
.Width(180)
.ClientTemplate("#: IsActive ? 'Yes' : 'No' #");
})
.ToolBar(toolbar =>
{
toolbar.Save();
toolbar.Search();
})
.Search(s =>
{
s.Field(e => e.IsActive);
s.Field(e => e.ProjectName, "contains");
})
.Sortable()
.Editable(GridEditMode.InCell)
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Field(p => p.ProjectManager).DefaultValue(
ViewData["defaultProjectManager"] as User);
model.Field(p => p.ProjectName).Editable(false);
})
.Read("Projects_Read", "Directory")
.Update("Projects_Update", "Directory")
))
With "s.Field(e => e.ProjectName, "contains");" it throws:
Uncaught TypeError: e.charAt is not a function kendo.all.js:2114
Without this, it runs correctly.
Additional question
Also, I would like to know how to search for value of bool variable. The variable is shown as yes, no words. When I search for no, it should show me records where value is false. How to implement this?
Hello Kva,
This issue usually occurs when there is mismatch between the field's type and the supported operators for that specific type. The "contains" filter operator is only supported by fields of type string.
Additionally, it seems that the ProjectName might contain some special symbols that could also cause the reported issue.
If the issue persists, even after the ProjectName type is set to string please consider sharing an example of the ProjectName field's values. This will enable me to try to replicate the reported issue on my side.
In regard to your second question - applying custom filters for boolean fields is currently not supported by the Grid's search. However, I will research whether any workaround is available and will let you know of my findings.
Regards,
Stoyan
Progress Telerik