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

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

问题描述

我在串联GridEditMode中使用kendo网格,并且GridInsertRowPosition设置为底部. Ajax用于数据绑定.启用了排序,并按DateTime字段进行了排序. 页面大小设置为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?

欢迎任何帮助. 谢谢!

Any help is welcome. Thank you!

推荐答案

您应该在工具栏中将自定义命令定义为:

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天全站免登陆