EasyUI treegrid 获取编辑状态中某字段的值 [getEditor方法获取不到editor]

如题,在treegrid里,按照api里getEditor方法的说明,

getEditor
options
Get the specified editor, the options contains two properties:
index: the row index.
field: the field name.

var nameEditor=$('#menuTable').treegrid('getEditor', {id:editingId,field:"name"});

 这样应该可以取到editor对象,但是测试发现只能获取到nameEditor=null,测试多次,很是恼火。

后来比较了下datagrid里的getEditor方法,

getEditor
param Get the specified editor, the param contains two properties:
id: the row node id.
field: the field name.

尝试着把上面treegrid getEditor中的id参数换成了index,值仍然使用id的值,果然,可以获取到editor对象了,再对此对象进行了一番属性遍历之后,终于找到了问题的解决办法,如下:

var nameEditor=$('#menuTable').treegrid('getEditor', {index:editingId,field:"name"});
var name=nameEditor.target.val();

由此,我敢保证官网api中关于treegrid的getEditor方法的说明是错误的,如果我的推测错误或者你有更好的思路或者解决办法,欢迎交流。

转载请注明出处:http://www.cnblogs.com/youryida  欢迎留言或qq交流(1140215489)
原文地址:https://www.cnblogs.com/youryida/p/3218119.html