easyui datagrid如何为某列绑定事件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了easyui datagrid如何为某列绑定事件相关的知识,希望对你有一定的参考价值。

页面上当用户输入数量的值,页面自动用单价乘以数量得到金额,并填充到金额字段

参考技术A 有一个事件 onDblClickCell
$('#dg').datagrid(
onDblClickCell: function(index,field,value)
$(this).datagrid('beginEdit', index);
var ed = $(this).datagrid('getEditor', index:index,field:field);
$(ed.target).focus();

);追问

我是上图则会中方式写的,但是这样写完后,页面上改过的行不能结束编辑状态

标红的不能再取消编辑状态了吗

jquery easyui 里的datagrid editor 如何绑定事件?

editor为text或numberbox我知道,其他比如:combogrid,combobox,datebox, 是怎么绑定的,我试了一下,只有text 能响应事件,方法如下:
editor.target.bind('focus',function()
alert('.....');
)

再次说明,此绑定方法在editor为text时响应的,但datebox,combogrid 等不能响应。。

参考技术A field: 'SysCode', title: '系统代码', width: 150, align: 'left', editor:
type: 'combobox',
options:

valueField: 'Key',
textField: 'Key',
url: '/Sys/SearchCodeInFunctionModel',
handler:function()
alert('something');





不知道到这种方式是不是可以。本回答被提问者和网友采纳
参考技术B 假的绑定可以的
field:'name',title:'name',width:70,align:'center',editor:type:'text',
formatter:function(value,row,index)
var s = '<a href="javascript:void(0)" onclick="abc()">'+value+'</a>';
return s;


这样的一个假的单击事件!
参考技术C 仔细看下api,datagrid的编辑器的控件都继承于父控件,事件响应是有限制的追问

API里没有editor事件的相关说明 。Tutorial 有个两列计算的例子,那个editor是numberbox ,网上有许多关于自定义事件的文章 ,但也都是 text numberbox

追答

我虽然没有一个个都试过,但是datebox绝对是可以的,本来想看下官网找点demo的,但是不知道为啥官网打不开了,那你只能自己研究了

追问

下边是为datagrid 增加了dblClickCell代码,测试后,还是只有 text 有响应。方便加我QQ807222175
onDblClickCell:function(index,field,value)
$(this).datagrid('beginEdit', index);
var ed = $(this).datagrid('getEditor', index:index,field:field);
$(ed.target).focus();
$(ed.target).select();

以上是关于easyui datagrid如何为某列绑定事件的主要内容,如果未能解决你的问题,请参考以下文章

如何为用作 DataGrid 的 ItemsSource 的项目的集合属性中的每个项目生成和绑定一列

easyui中的datagrid 如何通过url绑定数据

jquery easyui 里的datagrid editor 如何绑定事件?

EasyUI datagrid 明细表格中编辑框 事件绑定 及灵活计算 可根据此思路 扩展其他

EasyUI datagrid 明细表格中编辑框 事件绑定 及灵活计算 可根据此思路 扩展其他

easyui - 给textbox,datagrid中的编辑器,或者各种模块绑定事件的方法。