0
Im正在从数据库更新网格值。并将CS页面的值传递给JSgrid。删除,编辑与db完美配合。但搜索后网格没有得到更新。我可以将搜索值传递给CS页面,并从DB获取相应的搜索值。但是这些值没有被JSgrid更新。JSGrid未获取搜索值更新
var Status;
var lastPrevItem;
var clients =<%=gridData%>
$("#jsGrid").jsGrid({
width: "100%",
height: "450px",
filtering: true,
//filterable:true,
//inserting: true,
autosearch: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 25,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete the Department?",
controller: //db,
{ loadData: function (filter) {
if (filter["ID"] != "" || filter["Name"] != "") {
return $.ajax({
type: "POST",
async: true,
processdata: false,
paging: true,
contentType: "application/json; charset=utf-8",
url: "myurl/mycsmethod",
data: "{'ID':'" + filter["ID"] + "','Name':'" + filter["Name"]+ "'}",
success: function (data) {
},
error: function (XHR, errStatus, errorThrown) {
var err = JSON.parse(XHR.responseText);
errorMessage = err.Message;
alert(errorMessage);
}
});
}
},
updateItem: function (clients) {
var result = $.Deferred();
alert(result);
var ajaxDeferred = $.Deferred().reject();
alert(ajaxDeferred);
ajaxDeferred.done(function (updatedItem) {
result.resolve(updatedItem);
}).fail(function() {
result.resolve(lastPrevItem);
});
return result.promise();
},
},
onItemDeleting: function (args) {
//its working fine
},
onItemEditing: function (args) {
//its working fine
},
data: clients,
fields: [
{ type: "control" },
{ name: "ID", visible: false, width: 0, validate: "required" },
{ name: "Name", visible: false, width: 0, validate: "required" },
]
});
我想用jsgrid更新<%= gridData%>,一旦搜索按钮被触发。
'lodaData'应该总是返回一个承诺或静态数组。在你的工作示例中,你实现了客户端过滤。如果你想实现服务器端过滤(就像你上面的问题一样),只需要返回'$ .ajax'(不是有条件的)。过滤器会调用'loadData',它将发送过滤参数给服务器,由'$ .ajax'返回,promise将被过滤的数据解析,并且它应该按预期工作。 – tabalin