Hi,
I'm having trouble creating a custom filter textbox. I'm trying to add the filter with javascript syntax, but in the controller I'm seeing that request.Filters is null for some reason. Here's my code:
I'm having trouble creating a custom filter textbox. I'm trying to add the filter with javascript syntax, but in the controller I'm seeing that request.Filters is null for some reason. Here's my code:
@(Html.Kendo().Grid<
ToolWarehouseGUI.Models.ToolRowModel
>()
.Name("KendoGridTest")
.Columns(columns =>
{
columns.Bound(p => p.Name).Title("Nimike");
columns.Bound(p => p.Description).Title("Kuvaus");
columns.Bound(p => p.AmountAvailable).Title("Varastossa");
columns.Bound(p => p.AmountBooked).Title("Lainassa");
columns.Template(@<
text
>
<
a
class
=
"link-button"
href
=
"@Url.Action("
Edit", new {
toolid
=
item
.ToolId})">
<
span
class
=
"add-item"
>Muokkaa</
span
>
</
a
>
<
a
class
=
"link-button"
href
=
"@Url.Action("
Details", new {
toolid
=
item
.ToolId})">
<
span
class
=
"add-item"
>Lisätiedot</
span
>
</
a
>
</
text
>)
.ClientTemplate("<
a
class=\"link-button\" href=\"" + Url.Action("Edit", "Warehouse") + "?toolId=#=ToolId#" + "\">" +
"<
span
class=\"add-item\">Muokkaa</
span
>" +
"</
a
>" +
"<
a
class=\"link-button\" href=\"" + Url.Action("Details", "Warehouse") + "?toolId=#=ToolId#" + "\">" +
"<
span
class=\"add-item\">Lisätiedot</
span
>" +
"</
a
>")
.Title("Toiminnot");
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetTools", "Warehouse")
.Type(HttpVerbs.Post)
)
)
.Filterable(filtering => filtering
.Enabled(true)
)
.ToolBar(factory => factory
.Template(@<
text
>
<
div
>
Hakusana: @Html.TextBox("SearchText")
<
button
id
=
"searchBtn"
class
=
"ui-state-default ui-corner-all"
type
=
"submit"
>Hae</
button
>
</
div
>
</
text
>)))
<
script
>
function refreshGrid() {
$filter = new Array();
$filter.push({ field: "Name", operator: "contains", value: $('#SearchText').val() });
var grid = $("#KendoGridTest").data("kendoGrid");
grid.dataSource.filter($filter);
grid.dataSource.read();
}
$('#searchText').on("keypress", function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 13) {
refreshGrid();
return false;
}
});
$('#searchBtn').on("submit", function(e) {
refreshGrid();
return false;
});
</
script
>