gpt4 book ai didi

kendo-ui - 如何在ajax post回调后刷新Kendo Ui网格

转载 作者:行者123 更新时间:2023-12-02 14:09:32 25 4
gpt4 key购买 nike

ajax发布成功后如何刷新kendo ui网格?这是我的网格 ajax 帖子:

 var newUser = {
UserId: 0,
UserLoginName: currentRecord.UserLoginName,
UserDisplayName: currentRecord.UserDisplayName
};
//insert selected rows using DataSource insert method
destinationGrid.dataSource.insert(newRecord);
//ajax post to server
var url = '@Url.Action("CreateUser", "ManageUsers")';
$.post(url, { loginid: currentRecord.UserLoginName, name: currentRecord.UserDisplayName, role: roleSelected }, function (result) {
if (result.Success) {
**////grid is not refreshing as I want to refersh the grid again from database**
destinationGrid.dataSource.read();
}

});
}

最佳答案

这只是示例

 $.ajax({
url: '@Url.Action("NewGridView", "Test")',
type: "Post",
data: { sampleItem: sampleItem, sampleCode: sampleCode, sampledescription: sampledescription },
dataType: 'json',
success: function (result) {

$('#gridName').data("kendoGrid").dataSource = new kendo.data.DataSource({ data: result });
$('#gridName').data("kendoGrid").dataSource.read();
$('#gridName').data("kendoGrid").refresh();
}
});

Controller

 public JsonResult NewGridView(string sampleItem, string sampleCode, string sampledescription)
{

List<SampleModel> sampleAddList = new List<SampleModel>();
SampleModel sampleAdd = new SampleModel();
sampleAdd.SampleCode = sampleCode;
sampleAdd.SampleDescription = sampledescription;
sampleAdd.SampleItems = sampleItem;

sampleAddList.Add(sampleAdd);
var result = sampleAddList;
return Json(result, JsonRequestBehavior.AllowGet);
}

如果您需要在完成 Controller 操作后立即刷新网格,请执行此操作,

$('#gridName').data("kendoGrid").dataSource = new kendo.data.DataSource({ data: result });在你的post success

关于kendo-ui - 如何在ajax post回调后刷新Kendo Ui网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21668018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com