剑道格子在最后一页、最后一行位置插入新记录 [英] Kendo grid Insert new record on the last page, last row position

查看:15
本文介绍了剑道格子在最后一页、最后一行位置插入新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在内联 GridEditMode 和 GridInsertRowPosition 中使用剑道网格设置为底部.Ajax 用于数据绑定.排序已启用并按日期时间字段排序.页面大小设置为 10.

I'm using kendo grid in inline GridEditMode and GridInsertRowPosition set to bottom. Ajax is used for the data binding. Sorting is enabled and sorted by DateTime field. Page size is set to 10.

当有多个页面(超过 10 条记录)时会出现问题.我有一个 javascript 函数,可以跳转到最后一页并在底部显示新行.但是在某个时间点排序事件被触发,网格移动到只读模式.

To problem occur when there are multiple pages (more that 10 records). I have a javascript function that jumps to the last page and show new row at the bottom. But on some point sort event is triggered, and grid moves to read only mode.

是否有可能仅在添加新行的情况下阻止网格排序?

Is there a possibility to prevent Grid sorting only for the case when new row is added?

欢迎任何帮助.谢谢!

推荐答案

你应该在你的工具栏中定义一个自定义命令:

You should define a custom command in your toolbar as:

toolbar   : [
    {
        name : "my-create",
        text : "Add new record"
    }
],

然后,给它添加一个事件监听器,使用选择器 k-grid- 加上命令的名称.

Then, add an event listener to it, using as selector k-grid- plus the name of the command.

$(".k-grid-my-create", grid.element).on("click", function (e) {
}

最后我们将使用 Kendo UI 数据源的能力在特定点插入:

Finally we will use the ability of Kendo UI datasource for inserting in a specific point:

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

请注意,我们应该在插入行后移到最后一页.按日期排序的列应该没问题.

Please, realize that we should move to the last page after inserting the row. This should be ok with having columns sorted by date.

请检查这里的代码:http://jsfiddle.net/OnaBai/sAVGk/

这篇关于剑道格子在最后一页、最后一行位置插入新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆