我正在为 asp.net mvc 使用 Kendo UI Web。我通过网格命令按钮生成一个弹出窗口。关闭此弹出窗口后,我希望刷新网格。
在弹出窗口上关闭事件:
function ClosingRateWindow(e) {
var grid = $('#ContractDetailOrderEventGrid').data("kendoGrid");
grid.dataSource.read();}
此时网格未定义。
剑道窗口定义:
@(Html.Kendo().Window()
.Name("Rates")
.Title("Rates")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(850)
.Height(1200)
.Events(x => x.Close("ClosingRateWindow"))
)
Javascript 打开窗口(返回部分视图):
wnd.refresh({
url: BASE_APP_URL + "ContractRateAdmin/OpenContractRate/",
data: { data: data },
traditional: true
});
wnd.center();
wnd.open();
网格定义:
@(Html.Kendo().Grid<TMS.MVC.TIMS.Models.Admin.Contract.ContractOrderEventGridModel>()
.Name("ContractDetailOrderEventGrid")
.Columns(columns =>
{
columns.Command(o =>
{
o.Destroy();
o.Edit();
}).Width(100).Title("Commands");
columns.Command(command =>
{
command.Custom("Rates").Click("ShowRates");
}).Title("Rates").Width(120);
columns.Bound(o => o.ContractId).Hidden(true);
columns.Bound(o => o.OrderTypeId).Hidden(true);
//columns.Bound(o => o.ActiveRateMissing).Width(70).Title("Missing Rates?");
columns.Bound(o => o.OrderLevelFlag).Width(50).Title("Order Level").EditorTemplateName("ContractOE_OrderLevelFlag");
columns.Bound(o => o.Active).Width(80).Title("Active").EditorTemplateName("ContractOE_Active");
columns.Bound(o => o.InvoiceDescription).Width(150).Title("Invoice Desc");
columns.Bound(o => o.SourceContainerOwnerNameDisplay).Width(150).Title("Src Cont Owner").EditorTemplateName("ContractOE_SourceContainerOwner");
columns.Bound(o => o.DestContainerOwnerNameDisplay).Width(150).Title("Dest Cont Owner").EditorTemplateName("ContractOE_DestContainerOwner");
columns.Bound(o => o.SourceContainerTypeName).Width(150).Title("Src Cont Type").EditorTemplateName("ContractOE_SourceContainerTypeName");
columns.Bound(o => o.DestContainerTypeName).Width(150).Title("Dest Cont Type").EditorTemplateName("ContractOE_DestContainerTypeName");
columns.Bound(o => o.SourceContainerName).Width(150).Title("Src Container").EditorTemplateName("ContractOE_SourceContainerName");
columns.Bound(o => o.DestContainerName).Width(150).Title("Dest Container").EditorTemplateName("ContractOE_DestContainerName");
columns.Bound(o => o.EventAliasName).Width(150).Title("Event").EditorTemplateName("ContractOE_EventAliasName");
columns.Bound(o => o.ProductName).Width(150).Title("Product").EditorTemplateName("ContractOE_ProductName");
columns.Bound(o => o.OrderByNameDisplay).Width(150).Title("Order By").EditorTemplateName("ContractOE_OrderBy");
columns.Bound(o => o.OrderTypeName).Width(150).Title("Order Type").EditorTemplateName("ContractOE_OrderTypeName");
columns.Bound(o => o.EmployeeDisplay).Width(150).Title("Employee").EditorTemplateName("ContractOE_EmployeeDisplay");
columns.Bound(o => o.CarrierName).Width(150).Title("Carrier").EditorTemplateName("ContractOE_CarrierName");
})
.Events(e => e
.Save("Contract_Save")
//.Remove("ContractOrderEventGrid_Remove")
.DataBound("Contract_DataBound"))
.Scrollable(scrolling => scrolling.Enabled(true).Height("300px"))
.ToolBar(toolbar => {
if (Model.DetailModel.ContractAdminDetailPermissionModel.AddOrderEvent_Button_Visible == true)
toolbar.Create().Text("Add");
})
.HtmlAttributes(new { style = "width: 1200px" })
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(false))
.Resizable(resizing => resizing.Columns(true))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(true))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.ContractOrderEventId);
model.Field(x => x.ActiveRateMissing).Editable(false);
model.Field(x => x.ContractId).Editable(false);
model.Field(x => x.OrderTypeId).Editable(false);
model.Field(x => x.Active).Editable(true).DefaultValue("Y");
model.Field(x => x.OrderLevelFlag).Editable(true).DefaultValue("N");
model.Field(x => x.InvoiceDescription).Editable(true).DefaultValue("Enter Invoice Description");
model.Field(x => x.SourceContainerOwnerNameDisplay).Editable(true).DefaultValue("ALL");
model.Field(x => x.DestContainerOwnerNameDisplay).Editable(true).DefaultValue("ALL");
model.Field(x => x.SourceContainerTypeName).Editable(true).DefaultValue("ALL");
model.Field(x => x.DestContainerTypeName).Editable(true).DefaultValue("ALL");
model.Field(x => x.SourceContainerName).Editable(true).DefaultValue("ALL");
model.Field(x => x.DestContainerName).Editable(true).DefaultValue("ALL");
model.Field(x => x.EventAliasName).Editable(true).DefaultValue("ALL");
model.Field(x => x.ProductName).Editable(true).DefaultValue("ALL");
model.Field(x => x.OrderByNameDisplay).Editable(true).DefaultValue("ALL");
model.Field(x => x.OrderTypeName).Editable(true).DefaultValue("ALL");
model.Field(x => x.EmployeeDisplay).Editable(true).DefaultValue("ALL");
model.Field(x => x.CarrierName).Editable(true).DefaultValue("ALL");
})
.Events(x =>
{
// x.RequestEnd("RefreshContractDetailOrderEventGrid");
//x.Error("ContractDetailOrderEventGrid_Error");
})
.Create(update => update.Action("CreateContractOrderEvent", "ContractGrid", new { selectedContractId = Model.DetailModel.ContractId }))
.Read(read => read.Action("ReadContractOrderEvent", "ContractGrid", new { contractId = Model.DetailModel.ContractId }))
.Update(update => update.Action("UpdateContractOrderEvent", "ContractGrid", new { contractId = Model.DetailModel.ContractId }))
.Destroy(update => update.Action("DestroyContractOrderEvent", "ContractGrid"))
))
关于如何做到这一点的任何想法?