我的控制器是这样的:
[HttpPost]
public ActionResult Error_Search([DataSourceRequest] DataSourceRequest request, object[] ParaSearch)
{
object[] obj = new object[5];
obj[0] = Convert.ToInt32(ParaSearch[0]);
obj[1] = ParaSearch[1].ToString();
obj[2] = Convert.ToDateTime(ParaSearch[2]).AddDays(-10);
obj[3] = Convert.ToDateTime(ParaSearch[3]);
obj[4] = ParaSearch[4];
List<Vsoft.Lists.Model.SYS.SYS_Error> lst = new List<Vsoft.Lists.Model.SYS.SYS_Error>();
ResultMessage result = new Vsoft.Lists.DALEntity.SYS.DAL_Error().SelectToList(ref lst, obj);
return Json(lst.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
它将正确返回 Json(lst).. 但我无法将它绑定到数据源并在 Ajax 调用之后刷新 Grid,如下所示:
var requestData = { ParaSearch: arrObject };
$.ajax({
url: '@Url.Content("~/Error/Error_Search")',
data: JSON.stringify(requestData),
type: 'POST',
traditional: true,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
error: function (xhr) {
result = false;
alert('Error: ' + xhr.statusText);
},
success: function (lst) {
var grid = $("#Grid").data("kendoGrid");
grid.dataSource.data(lst);
grid.refresh();
},
async: true,
processData: false,
cache: false
});
AnyOne 可以帮我解决这个问题吗?谢谢大家!