代码:
var dg = $(DataGrid.TableGridID); var row = { ID: "", UserName: "", Password: "", IsRemembered: "", CreateTime: "" }; dg.datagrid('insertRow', { index: 0, row: row }); var selectIndex = dg.datagrid('getRowIndex', row); dg.datagrid('beginEdit', selectIndex); var ed = dg.datagrid('getEditor', { index: 0, field: 'UserName' }); $(ed.target).focus();