我正在向 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/(注释掉标记为编辑的行并添加新行)
谢谢