gpt4 book ai didi

javascript - Kendogrid 不刷新

转载 作者:行者123 更新时间:2023-12-02 14:03:13 24 4
gpt4 key购买 nike

我有一个 kendogrid,可以从服务器提取数据并填充它。好吧,我在客户端模板中有一个自定义按钮,它显示在每行的末尾。当我修改此行时,更改会在数据库中进行,但不会反射(reflect)在网格中。

最奇怪的是,当我第二次单击该按钮时,它确实起作用了。

代码如下:

$('#custom-generic-modal.modal-content').off('click', '#btnSave').on('click', '#btnSave', function () {

var permissions = $('#divNav .k-state-selected').attr('data-permissionid');
var currentPage = grid.dataSource.page();

$.ajax({
//global: false,
type: 'GET',
url: 'Allergy/AllergiesTab?permissions=' + permissions,
async: 'false',
success: function (page) {
$("#PageDiv").html(page);
console.log('success')
},
complete: function () {
$.get("Page/PageTab?permissions=" + permissions, function(page) {
$("#PageDiv").html(page);
helpers.notify("Retraction successful.", "success");
}).done(function() {
var grid = $("#Grid").data("kendoGrid");
grid.dataSource.page(currentPage);
grid.refresh();
console.log('complete')
});
}
});

});

这是我的网格:

@(Html.Kendo().Grid(Model.grid)
.Name("Grid")
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height: 450px;" })
.Columns(c =>
{
c.Bound(x => x.IsAllergy).Title("").Width("13%").ClientTemplate(@"<span class='#if(IsRetracted){#strike-through#}#'>#if (IsAllergy){#<span><b> Allergy </b></span>#}# #if (!IsAllergy){#<span><b> Sensitivity </b></span>#}# </span>");
c.Bound(x => x.AllergyDescription).Title("Allergen/Sensitivity").Width("24%").ClientTemplate(@"<span class='#if(IsRetracted){#strike-through#}#'>#if (AllergyDescription != null){#<span><b> #= AllergyDescription # </b></span>#}# #if (AllergyDescription == null){#<span><b> N/A </b></span>#}# </span>");
//AllergyType(Food,drug,ev)
c.Bound(x => x.AllergySeverityDescription).Title("Severity").Width("13%").ClientTemplate(@"<span class='#if(IsRetracted){#strike-through#}#'>#if (AllergySeverityDescription != null){#<span> #= AllergySeverityDescription # </span>#}# #if (AllergySeverityDescription == ''){#<span> N/A </span>#}# </span>");
c.Bound(x => x.AllergyReactionDescription).Title("Reaction").Width("13%").ClientTemplate(@"<span class='#if(IsRetracted){#strike-through#}#'>#if (AllergyReactionDescription != null){#<span> #= AllergyReactionDescription # </span>#}# #if (AllergyReactionDescription == ''){#<span> N/A </span>#}# </span>");
c.Bound(x => x.TreatmentComments).Title("Treatment Comments").Width("24%").ClientTemplate(@"<span class='#if(IsRetracted){#strike-through#}#'>#if (TreatmentComments != null){#<span> #= TreatmentComments # </span>#}# #if (TreatmentComments == null){#<span> N/A </span>#}# </span>");
c.Template(@<text></text>)
//.ClientTemplate(@" #if(!IsActive) {#<a class='notes-btn'><span class='glyphicon glyphicon-pencil'></span></a> #if(!IsRetracted) {#<a class='notes-btn' onclick='retractAllergyInit(#= PersonAllergyId #)'><span class='glyphicon glyphicon-minus-sign'></span></a>#}}#")
.ClientTemplate(@" #if(!IsActive) {#<a class='notes-btn'><span class='glyphicon glyphicon-pencil'></span></a> #if(!IsRetracted) {#<a class='notes-btn modal-link' href='Retract/Retract?typeId=#= PersonAllergyId #&retractType=5' data-ajax='true' data-ajax-method='GET' data-ajax-mode='replace'><span class='glyphicon glyphicon-minus-sign'></span></a>#}}#")
.Title("Actions").Width("12%");
}
)
.Pageable(pager => pager.Messages(m => m.Empty("No Results Found")))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.ServerOperation(false))
)

最佳答案

grid.refresh() “使用当前数据项呈现所有表行。” http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-refresh

我没有看到任何导致数据源从服务器重新读取的代码。

尝试做

 grid.dataSource.read();

相反,它将始终重新命中 dataSource.transport.read 中配置的服务器操作。

您应该提供网格配置代码以提供更多详细信息。

关于javascript - Kendogrid 不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40244749/

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