Dojo按事件处理程序启用按钮



我使用的是IBM Content Navigator 2.0.3,它使用DOJO 1.8进行GUI开发。我是dojo的新手,我必须增强其中一种形式:向dataGrid添加一个事件处理程序,这样当网格的行被选中时,其中一个按钮就会被启用。我已经设法添加了本期中建议的事件处理程序:dojo datagrid事件附加问题但我仍然无法启用按钮。这是表单的html:

添加去除
<div class="selectedGridContainer" data-dojo-attach-point="_selectedDataGridContainer">                     
<div class="selectedGrid" data-dojo-attach-point="_selectedDataGrid" ></div>
</div>

所附图像描述了它的外观在此输入图像描述。在此处输入图像描述postCreate函数的js文件代码如下:

postCreate: function() {
        this.inherited(arguments);
        this.textDir = has("text-direction");
        domClass.add(this._selectedDataGridContainer, "hasSorting");
        this._renderSelectedGrid();
        this.own(aspect.after(this.addUsersButton, "onClick", lang.hitch(this, function() {
            var selectUserGroupDialog = new SelectUserGroupDialog({queryMode:"users", hasSorting:true, callback:lang.hitch(this, function (user) {
                this._onComplete(user);
                this._markDirty();
            })});
            selectUserGroupDialog.show(this.repository);
        })));
        this.own(aspect.after(this.removeUsersButton, "onClick", lang.hitch(this, function() {
            if (this._selectedGrid != null) {
                var selectedItems = this._selectedGrid.selection.getSelected();
                if (selectedItems.length > 0) {
                    array.forEach(selectedItems, lang.hitch(this, function(item) {
                        this._selectedGrid.store.deleteItem(item);
                    }));
                }
                this._selectedGrid.selection.clear();
                this._selectedGrid.update();
            }
            this._markDirty();
        })));
// the following handler was added by me
        dojo.connect(this.myGrid, 'onclick', dojo.hitch(this, function(){
            console.log(" before ");
        this.removeUsersButton.set('disabled', true);
            console.log(" after ");
        }));
    },

所以this.own(aspect.after(this.removeUsersButton….)工作正常,在我的干扰之前工作。所以它以某种方式访问this.Remove UsersButton并处理事件。但我的处理程序dojo.connect(this.myGrid….)只在前后打印console.log(),而没有启用Remove按钮。Button没有Id,只有数据dojo连接点。选择daaGrid时,如何启用"删除"按钮?

使用this.removeUsersButton.set('disabled',true);您正在将该按钮设置为禁用。如果要启用它,则需要将其设置为false。

this.removeUsersButton.set('disabled', false);

最新更新