【问题标题】:Appending a new row in kendoUI gives TypeError: Cannot read property 'replace' of undefined在 kendoUI 中添加新行会导致 TypeError: Cannot read property 'replace' of undefined
【发布时间】:2014-12-22 18:22:21
【问题描述】:

我需要在底部的剑道网格中添加一个新行,按下按钮,但我为其中一列定义了一个模板,并且在该模板中出现错误说“无法读取未定义的属性'替换'” .

这是我试图用于上述操作的代码:

var dataSource = grid.dataSource;
var total = dataSource.data().length;
dataSource.insert(total, {});
dataSource.page(dataSource.totalPages());
grid.editRow(grid.tbody.children().last());

我希望新网格处于可编辑模式。请提供任何帮助

【问题讨论】:

标签: kendo-ui


【解决方案1】:

我相信“替换”是 yourdataItem 中的字段之一?您必须在创建网格时定义所有新的行默认值:

$("#grid").kendoGrid({
    dataSource: {
        data: data,
        schema: {
            model: {
                fields: {
                    replace: {
                        defaultValue: "your value",
                    }
                }
            }
        }
    }
...
});

或者当你插入新行时:

dataSource.insert(total, { replace : "your value" });

【讨论】:

  • 感谢您的回复,但我自己找到了答案。我错过了指定虚拟 json 对象行,匹配网格记录即 {'field1': '', 'field2': '' , ..} 需要在预期字段上应用替换(通过模板) - 以便它:)
猜你喜欢
  • 2021-03-16
  • 2021-06-25
  • 2023-04-06
  • 1970-01-01
  • 2017-04-24
  • 2023-03-15
  • 2021-09-18
  • 2021-09-25
  • 1970-01-01
相关资源
最近更新 更多