Telerik ASP.NET MVC Q2 2011
我有一个Ajax绑定的网格:
@(Html.Telerik().Grid<IUser>()
.Name("UsersGrid")
.DataBinding(binding => binding.Ajax().Select("UsersGridSelect", "User", new { area = "Admin" }))
.ClientEvents(events => events.OnDataBinding("onGridRefresh"))
...
...
这是我的onGridRefresh处理程序:
function onGridRefresh(e)
{
var modelData =
{
Username: $('#SearchModel_Username').val(),
FirstName: $('#SearchModel_FirstName').val(),
LastName: $('#SearchModel_LastName').val(),
IsLocked: $('#SearchModel_IsLocked').is(':checked'),
ClientId: $('#SearchModel_ClientId').val(),
UserCode: $('#SearchModel_UserCode').val(),
ExpireDateFrom: $('#SearchModel_ExpireDateFrom').val(),
ExpireDateTo: $('#SearchModel_ExpireDateTo').val()
};
e.data = { searchModel: modelData };
}
这是我的控制者:
[GridAction]
public ActionResult UsersGridSelect(UserSearchModel searchModel)
{
IList<IUser> userList = searchModel == null ? new List<IUser>() : _repository.GetUsers(searchModel);
return View(new GridModel(userList));
}
这个设置不起作用,我知道......但至少它证明了我的追求。 当我将我的值作为单独的参数传递时,它可以工作:
public ActionResult UsersGridSelect(string Username, string Firstname, string LastName,....)
但我会优先把它作为一个对象传递。有没有办法实现这个目标?
答案 0 :(得分:0)
如果你使用
e.data = modelData
它会正确绑定。