在dojo.gridX中添加新行时如何聚焦第二个Cell

How to focus second Cell when add a new row in dojo.gridX

本文关键字:聚焦 Cell 第二个 何聚焦 gridX dojo 添加 新行时      更新时间:2023-09-26

我使用dojo.gridx来显示我的值。有时用户可以创建一个新行。因此,我已经添加了一个新的按钮,当点击newRow按钮,将调用onclick方法。

在该方法中创建了新的行代码。我的代码如下:

addRow:

function() {
    var that = this;
    var gridIdLocal = dijit.byId('GridId');
    that.lastIndex+=1;  ( last index count I get externally)    
    var newRow = {
        Id : '',
        ClassDES:'',
        createdDate: that.getTodayDate(),
        activatedDate:that.getTodayDate(),
        deactivedDate:'',
        activeStatus:'Y',
        id : lastIndex
    };
    gridIdLocal.store.newItem(newRow);
    gridIdLocal.store.save();            
}, 

通过这段代码,我能够创建一个新的行,但我想把鼠标光标指向新添加的行的第二列(ClassDES)。
如何在dojo.gridx中实现此功能?

我没有使用过Dojo gridx,但是看看它的一个基本演示,它在<div>中为每一行呈现一个<table>。使用上面示例中的newRow对象,您可以使用jquery

执行如下操作
function() {
    var that = this;
    var gridIdLocal = dijit.byId('GridId');
    that.lastIndex+=1;  ( last index count I get externally)    
    var newRow = {
        Id : '',
        ClassDES:'',
        createdDate: that.getTodayDate(),
        activatedDate:that.getTodayDate(),
        deactivedDate:'',
        activeStatus:'Y',
        id : lastIndex
    };
    gridIdLocal.store.newItem(newRow);
    gridIdLocal.store.save();  
    $(newRow).find("td")[1].children("input").focus();
}, 

如果你能张贴一个工作的表格,这将更容易解决。