我有一个我们在搜索页面上使用的Kendo UI网格:
@(Html.Kendo().Grid<SMT.Models.SpecimenDetail>()
.Name("SpecimenDetailGrid")
.Columns(columns =>
{
columns.Bound(e => e.uniqueID).Hidden();
columns.Bound(e => e.contact_business_email).Width(120).Title("Owner Email");
columns.Bound(e => e.contact_business_phone).Width(120).Title("Owner Phone");
})
.ToolBar(tools =>
{
tools.Excel();
tools.Custom().Text("Back to Specimen Summary").HtmlAttributes(new { id = "goBack", style = "margin-left: 880px;" });
})
.Excel(excel => excel
.AllPages(true)
.FileName("SpecimenDetailGridData.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Home"))
)
.Resizable(x => x.Columns(true))
.Reorderable(x => x.Columns(true))
.HtmlAttributes(new { style = "height:500px;" })
.Pageable()
.AutoBind(false)
.Editable(e => e.Mode(GridEditMode.InLine))
.DataSource(datasource => datasource
.Ajax()
.Model(model => {
model.Id(p => p.uniqueID);
model.Field(p => p.SampleID).Editable(false);
model.Field(p => p.company_business_name).Editable(false);
// disable company name on edit
// model.Field(p => p.company_business_name).Editable(false);
})
.Read(read => read.Action("GetSpecimenDetail", "Home").Data("FillSearchParms"))
.Update(update => update.Action("UpdateSpecimen", "Home").Data("FillUpdateParms"))
.Destroy(destroy => destroy.Action("DeleteSpecimen", "Home"))
.PageSize(10)
.Events(e => { e.RequestEnd("onRequestEnd");})
)
)
在同一页面上,我们有一个调用jQuery函数的按钮来刷新网格:
$(document).ready(function () {
$("#SearchBtn").click(function (e) {
e.preventDefault();
$("#divSearchSpecimenDetail").attr("style", "display: block;");
var grid = $("#SpecimenDetailGrid").data("kendoGrid");
//think this is the problem
grid.datasource.data = "FillSearchParams";
grid.dataSource.read();
grid.refresh();
e.preventDefault();
hideColumns(specimenCat);
$("#searchbar").data("kendoPanelBar").collapse($("li.k-state-active"));
})
});
和另一个选择搜索参数的jQuery函数:
function FillSearchParms() {
var units = defaultDDObj("Units");
var specimenCat = defaultDD("SpecimenCategory");
//debugger;
var searchParms = {
SpecimenCategory: specimenCat,
Units: units.Value,
uniqueID: $("#uniqueID").val(),
SampleID: $("#SampleID").val(),
ThicknessAtWeld1From: $("#ThicknessAtWeld1From").val(),
ThicknessAtWeld1To: $("#ThicknessAtWeld1To").val(),
OverlayThicknessFrom: $("#OverlayThicknessFrom").val(),
OverlayThicknessTo: $("#OverlayThicknessTo").val(),
}
问题是,无论出于何种原因,单击按钮都会调用读取操作,而不是FillSearchParams调用。更新的剑道和jQuery,所以我想我只是格式化线:
grid.datasource.data = "FillSearchParams";
按钮调用中的。
提前致谢。