Paul  Atreides
Paul Atreides

Reputation: 1

Dojo enable button by event handler

I am working with IBM Content Navigator 2.0.3, that uses DOJO 1.8 for the GUI development. I am new in dojo, and I have to enhance one of the forms: add an event handler to the dataGrid so when the row of the grid is selected one of the buttons become enabled. I've managed to add event handler as was advised in this issue: dojo datagrid event attach issue but I still can't enable the button. Here is html of the form:

Add Remove
<div class="selectedGridContainer" data-dojo-attach-point="_selectedDataGridContainer">                     
<div class="selectedGrid" data-dojo-attach-point="_selectedDataGrid" ></div>
</div>

The attached image describes how it looksenter image description here.enter image description here And the js file code of postCreate function is following:

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 ");
        }));

    },

so this.own(aspect.after(this.removeUsersButton..... works fine and worked before my interference. So it somehow accesses this.removeUsersButton and processes the event. But my handler dojo.connect(this.myGrid.... only prints console.log() before and after without enabling the Remove button. The Button has no Id, only data-dojo-attach-point. How do I enable the Remove button when the daaGrid is selected?

Upvotes: 0

Views: 598

Answers (1)

T Kambi
T Kambi

Reputation: 1387

With this.removeUsersButton.set('disabled', true); you are setting the button to be disabled. If you want to enable it you need to set it to false.

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

Upvotes: 1

Related Questions