我在 Kendo Grid 中成功创建了按钮,如下所示,按钮实际上是在<a href="#" onClick="showDetails ..... >
columns: [
{ field: "Title", width: "90px", title: "Event<br />Name" },
{ field: "StartDate", title: "Event<br />Date", width: 35 },
{ field: "Keywords", title: "Event<br />Type", width: 35 },
{ field: "TotalDollars", title: "Total<br />Collected", width: 20 },
{ field: "TotalTransactions", title: "# of<br />Trans.", width: 20 },
{ field: "TotalAttending", title: "# of<br />Attending", width: 30 },
{ field: "SocialViews", title: "# of<br />Views", width: 30 },
{ command: { text: "ManageEvent", click: showDetails }, title: " Edit Event", width: "60px" },
{ command: { text: "ViewEvent", click: showEvent }, title: " View Event", width: "60px" }
]
现在我想更改其中的一些属性,如果我将更改放入函数中showDetails()
它可以正常工作,但这似乎有点尴尬,然后在单击函数上更改属性,然后再执行更多代码。
这有效
function showEvent(e) {
$('.k-grid-ViewEvent').attr('target', '_blank');
var event = this.dataSource.getByUid(this.select().data("uid"));
var id = event.ID;
window.location = "epage.aspx?e=" + id;
}
但这不是,我什至尝试在其中放置一个 TimeOut 以等待网格渲染,但仍然没有。
$(function () {
setTimeout(
$.each('.k-grid-ViewEvent', function () {
$(this).attr('target', '_blank');
var event = this.dataSource.getByUid(this.select().data("uid"));
var id = event.ID;
$(this).attr('href', id);
}), 4000);
});
任何人都知道如何,最好是在 jQuery 中,但我并不关心如何在使用 Kendo Grid Plugin 渲染这些命令后动态更改这些命令?