这是我的剑道网格帖子方法我想在剑道网格中对测试名称执行filtring我尝试过使用javscript但它没有为我工作
控制器
[HttpPost]
public ActionResult TestNotification(DataSourceRequest command)
{
EAssessmentNew.BAL.StudentBal studBal = new EAssessmentNew.BAL.StudentBal();
int studentId = Convert.ToInt32(studBal.getStudentId(Session["sname"].ToString()));
PageList<Test> TestDetails = studBal.testDetails(studentId, command.Page - 1, command.PageSize);
var gridModel = new DataSourceResult
{
Data = TestDetails.Select(x =>
{
var TestModel = new Test();
TestModel.Test_Id = x.Test_Id;
TestModel.Test_Name = x.Test_Name;
TestModel.Test_Date = x.Test_Date;
TestModel.Start_Time = x.Start_Time;
TestModel.End_Time = x.End_Time;
return TestModel;
}),
Total = TestDetails.TotalCount,
};
return Json(gridModel);
}
Kendo JQuery On View
<script>
$(document).ready(function () {
$("#test-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("TestNotification", "Student"))",
type: "POST",
dataType: "json",
data: '',
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
error: function (e) {
display_kendoui_grid_error(e);
this.cancelChanges();
},
pageSize: 2,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true,
pageSizes: [10, 20, 30]
},
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
columns: [
{
field: "Test_Name",
title: "Name",
filterable: true,
width: 10
// template: '<a title="Edit" href="/Admin/ViewCategoryDetails?categoryId=#=CategoryId#&categoryName=#=CategoryName#"><span class="k-icon k-edit"></span></a>'
},
{
field: "Test_Date",
title: "Test Date",
// template: '#= kendo.toString(kendo.parseDate(Test_Date, "dd/MM/yyyy" )) #',
template:"#= kendo.toString(new Date(parseInt(Test_Date.substr(6))),'dd-MM-yyyy ')#",
width: 10
},
{
field: "Start_Time",
title: "Start Time",
width: 10,
// template: '<a onClick="return callConfirmationbox();" title="delete" href="/Admin/DeleteParentCategory?categoryId=#=CategoryId#"><span class="k-icon k-delete"></span></a>'
},
{
field: "End_Time",
title: "End Time",
width: 10,
// template: '<a title="Edit" href="/Admin/ViewCategoryDetails?categoryId=#=CategoryId#&categoryName=#=CategoryName#"><span class="k-icon k-edit"></span></a>'
},
{
field: "Test_Id",
title: "Action",
width: 10,
template: '<a title="Apply" href="/Student/ApplyForTest?TestId=#=Test_Id#">Click To Apply</a>'
}]
});
});
上面是我对kendo网格的jquery如何对网格中的测试名称执行过滤我尝试过使用javascript我在控制器上有一个GetTestList方法,它返回一个测试列表,但它不能从filterin的角度来看任何帮助将不胜感激
答案 0 :(得分:0)
如果要返回所有正在流动的数据
,您可以轻松地进行Loal过滤$("#test-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("TestNotification", "Student"))",
type: "POST",
dataType: "json",
data: '',
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors"
},
error: function (e) {
display_kendoui_grid_error(e);
this.cancelChanges();
},
pageSize: 2,
//serverPaging: true,
//serverFiltering: true,
//serverSorting: true
},
pageable: {
refresh: true,
pageSizes: [10, 20, 30]
},
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
filterable: true,
sortable: true,
columns: [
{
field: "Test_Name",
title: "Name",
filterable: true,
width: 10
},
{
field: "Test_Date",
title: "Test Date",
width: 10
},
{
field: "Start_Time",
title: "Start Time",
width: 10,
},
{
field: "End_Time",
title: "End Time",
width: 10,
},
{
field: "Test_Id",
title: "Action",
width: 10,
template: '<a title="Apply" href="/Student/ApplyForTest?TestId=#=Test_Id#">Click To Apply</a>'
}]
});
如果您需要执行服务器分页和过滤,则应修改您的传输,并阅读您的操作。
//serverPaging: true,
//serverFiltering: true,
//serverSorting: true
上面将在启用它们时调用读取操作并传递页面大小,过滤对象等。因此,您应该在阅读操作中接受这些参数并返回过滤后的数据或页面数据
我会将read作为函数编写,这样我就可以管理发送到action
的参数了transport: {
read: function (options) {
// the option will have pagesize (eg:option.pagesize ) when paging
// the option will have filter OBJ (eg:option.filter[]) when filtering
$.ajax({
url: "@Html.Raw(Url.Action("TestNotification", "Student"))",,
dataType: "json",
data: {pageSize:option.pagesize }, // send the data accordingly (not sure exact syntax but its available in the option parameter)
cache: false,
success: function (result) {
options.success(result);
},
error: function (result) {
options.error(result);
}
});
},
}