【发布时间】:2020-01-17 06:41:01
【问题描述】:
我正在为 jQuery 使用 Kendo UI。我的网格有 2 列:浮点数和文本。当值发生变化时,我需要得到一个网格行。对于数字字段,一切正常,但对于文本字段,它不会:调用处理函数,但我如何获取其中的网格数据? (我使用相同的处理程序,但没关系)。
export class MyGrid {
constructor() {
let that: MyGrid = this;
$("#MyGrid").kendoGrid({
dataBound: function (e) {
this.tbody.find(".MyNumericValue").each(function () {
$(this).kendoNumericTextBox({
format: "n3",
decimals: 3,
change: that.onValueChange.bind(that)
});
});
// Event function is called, but how to get row data?
this.tbody.find(".MyTextValue").each(function () {
$(this).on("change", that.onValueChange.bind(that))
});
}
});
}
}
列:
let columns = [
{
title: "Decimal value",
field: "RoadLength",
template: "<input name='RoadLength' class='MyNumericValue' value='#: RoadLength #' />"
},
{
title: "Text value",
field: "Name",
template: "<input name='Name' class='k-textbox MyTextValue' value='#: Name #' />"
}
];
事件:对于文本框“e.sender.element.closest("tr")”不起作用。
onValueChange(e: any): void {
let g = $("#MyGrid").data("kendoGrid");
let dataItem = g.dataItem(e.sender.element.closest("tr"));
let name: string = e.sender.element[0].name;
let value = e.sender.value();
// dataItem.set(name, value);
}
【问题讨论】:
标签: javascript jquery typescript kendo-ui kendo-grid