如何在dojox.grid.DataGrid中聚焦新添加的行的第一个单元格
发布时间:2020-12-16 21:18:43 所属栏目:百科 来源:网络整理
导读:我正在向dojox.grid.DataGrid添加一个新的空行,并希望将焦点放在新行的第一个单元格中. 我通过调用添加行: var new_row = {},attributes = store.getAttributes( items[0] );dojo.forEach( attributes,function( attribute ){ dojo.forEach( attributes,fun
我正在向dojox.grid.DataGrid添加一个新的空行,并希望将焦点放在新行的第一个单元格中.
我通过调用添加行: var new_row = {},attributes = store.getAttributes( items[0] ); dojo.forEach( attributes,function( attribute ) { dojo.forEach( attributes,function( attribute ) { new_row[ attribute ] = null; } ); } ); store.newItem( new_row ); 我相信以下代码将重点关注: grid.focus.setFocusIndex( row_index,0 ); grid.edit.setEditCell( grid.focus.cell,row_index ); 但我无法弄清楚如何在网格重新渲染后才调用此代码.我想我需要连接到一个事件.但是,我看不到可能发生的事件.似乎在添加新行之前调用onNew(). 这是一个JSFiddle,尽可能接近解决方案. http://jsfiddle.net/xDUpp/(注释掉标记为编辑的行并添加新行) 谢谢 解决方法
您对哪个版本的Dojo感兴趣?
Dojo API在ver之间有所不同.在这件事上. 看着: 修改商店后,网格需要一点时间来重建自己,所以setFocusIndex& setEditCell也必须延迟工作: store.onNew = function( new_item ) { var rowIndex = new_item._0; window.setTimeout(function() { grid.focus.setFocusIndex( rowIndex,0 ); grid.edit.setEditCell( grid.focus.cell,rowIndex ); },10); }; 格尔茨 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |