我需要获取剑道网格的显示文本,同时迭代数据。我这样做了:
var data = grid.dataSource.data();
var cols = grid.columns;
for (var ri = 0; ri < data.length; ri++) {
for (ci = 0; ci < cols.length; ci++) {
var val = data[ri].get(cols[col].field);
//do something with the cell data
//but this gets me the model's value, not the displayed text
}
}
如何在每个单元格中显示文本?
答案 0 :(得分:2)
好的,想通了。
var data = grid.dataSource.data();
var cols = grid.columns;
var field, template;
for (var ri = 0; ri < data.length; ri++) {
for (ci = 0; ci < cols.length; ci++) {
field = cols[ci].field;
template = cols[ci].template;
if (field) {
var textval = data[ri][field];
if (template) {
var kt = kendo.template(template.toString());
textval = kt(data[ri]);
valType = 'string';
}
//do something with textval here
}
}
}