1

我正在使用以下代码:

launch: function() {
    Rally.data.ModelFactory.getModel({
        type: 'UserStory',
        success: function(model) {
            this.down('#gridContainer').add({
                xtype: 'rallygrid',
                model: model,
                columnCfgs: [
                    {
                        text: 'ID',
                        dataIndex: 'FormattedID',
                        width: 75
                    },
                    {
                        text: 'Name',
                        dataIndex: 'Name',
                        width: 500,
                        listeners: {
                            click: this._showTasks,
                            scope: this
                        }
                    }
                ]
            });
        },
        scope: this
    });
}

当用户从网格中单击用户故事时会调用函数 _showTasks,但我无法获取他们单击的用户故事的 ID。如果我console.log(this)我可以看到 ID 存储在一个名为selected的项目数组中,但我不确定该属性的路径。我还觉得可能有一种更简单的方法可以从网格中获取最近选择的用户故事?

最终目标是列出所选用户故事的所有子任务,或者在另一个拉力网格中,或者直接将它们打印到正文中。

4

1 回答 1

1

而不是在列上注册点击处理程序,您应该能够在网格上注册选择处理程序:

{
    xtype: 'rallygrid',
    //...
    //more grid config
    //...
    listeners: {
        select: this._onSelect,
        scope: this
    }        
}

然后在您的 onSelect 处理程序中,您有记录:

_onSelect: function(rowModel, record, rowIndex, options) {
    var id = record.get('ObjectID');
}
于 2012-07-24T12:18:27.943 回答