0
我有一個kendogrid,當我添加新記錄並重新綁定網格時,新記錄不在網格中,但是如果我使用過濾器然後我看到它,但要真正在網格中看到它,我必須刷新頁面。當重新綁定網格時沒有刷新新記錄,但在過濾時發現新記錄
頁面加載它調用此函數
function GetCustomerGridData() {
kendo.ui.progress($("#Customer-Grid"), true);
$.ajax({
type: "GET",
url: URLParam.GetActiveCustomersForTheGrid,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data, textStatus, jqXHR) {
LoadCustomerGrid(data);
kendo.ui.progress($("#Customer-Grid"), false);
}
});
}
的LoadCustomerGrid是這個
function LoadCustomerGrid(newData) {
CreateCustomerGrid(newData);
}
網格本身是..
var customerGrid,
CreateCustomerGrid = function (newData) {
customerGrid = $("#Customer-Grid").kendoGrid({
dataSource: {
data: newData
},
schema: {
model: {
CustomerID: { type: "number" }
}
},
filterable: {
mode: "row"
},
columns: [
{
template: "<input type='checkbox' class='checkbox' />",
width: "30px"
}
{
field: "LastName",
title: "Last Name",
filterable: {
cell: {
showOperators: false,
operator: "contains",
inputHeight: "34px"
}
}
},
{
field: "FirstName",
title: "Name",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Phone",
title: "Phone",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Address",
title: "Address",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "City",
title: "City",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
},
{
field: "Zip",
title: "Zip",
filterable: {
cell: {
showOperators: false,
operator: "contains"
}
}
}
],
scrollable: true,
sortable: true,
pageable: {
pageSize: 20
},
selectable: "row",
height: $("#Customer-Grid").closest(".col-height-full").height() - 60,
change: function (e) {
// Function call goes here
var detailRow = this.dataItem(this.select());
var optionID = detailRow.get("CustomerID")
}
}).data("kendoGrid");
}
當我去添加一條記錄我使用彈出式菜單
function CustomerPopupEditor() {
$("#showCustomerEdit").append("<div id='window'></div>");
var myWindow = $("#window").kendoWindow({
position: {
top: 100,
left: "30%"
},
width: "40%",
title: "Add Customer",
content: "/Customer/CustomerEditor",
modal: true,
actions: [
"Close"
],
close: function (e) {
$("#window").data("kendoWindow").destroy();
}
}).data("kendoWindow");
myWindow.open();
GetStates();
HomeStorage.Keys.AddOrEdit = "Add";
}
,當添加一個新的記錄,然後單擊保存按鈕,該功能被稱爲
function SubmitNewCustomer() {
var customer = NewCustomerToSubmit();
GetAssignmentIDs();
$.ajax({
type: "POST",
url: URLParam.AddNewCustomer + "?assignments=" + HomeStorage.Keys.AssignmentIDString,
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(customer),
success: function (data, textStatus, jqXHR) {
HomeStorage.Keys.NewCustomerID = data.id;
},
complete: function (e) {
GetCustomerGridData();
ClearFields();
}
})
}
,當我關閉按鈕上單擊事件彈出這就是所謂的
$("#btnCancel").click(function() {
ClearFields();
GetCustomerGridData();
CloseTheWindow();
});
在SubmitNewCustomer函數我曾嘗試將GetCustomerGridData()放入它的成功函數中,但也沒有奏效。
爲GetCustomerGridData()返回的數據有超過30K條記錄,但我不認爲這應該很重要。
任何想法我失蹤?