2016-05-12 8 views
0

私はIBM Content Navigator 2.0.3を使用しており、DOJO 1.8をGUI開発に使用しています。私はdojoで新しく、フォームの1つを拡張する必要があります。イベントハンドラをdataGridに追加すると、グリッドの行が選択されたときにボタンの1つが有効になります。 この問題でアドバイスされたイベントハンドラを追加できました:dojo datagrid event attach issue ボタンを有効にすることはできません。ここでは、フォームのHTMLは次のとおりです。イベント・ハンドラーによるDojo有効化ボタン

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

を削除 を追加添付画像は、それがenter image description hereをどのように見えるかを説明します。 enter image description here との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は.....正常に動作し、私の干渉の前に働いていた、それは何らかの形でこれをアクセスするようにします。私のハンドラdojo.connect(this.myGrid ....)は、Removeボタンを有効にしないでconsole.log()を表示するだけです。ButtonにはIdがありません。data-dojo-attach-ポイントを追加するにはどうすればよいですか?

答えて

1

this.removeUsersButton.set( 'disabled'、true);ボタンを無効にするように設定しています。それを設定する偽にする。

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

AAAA!どのような単純な間違いを私は作った!どうもありがとうございます !!! )) –

+0

後でハンドラを切断する必要がありますか? YESの場合、そのコードはどこに置くべきですか? –

+0

必須ではありません。イベント内の実装によって異なります。あなたが何かを更新しているなら、あなたは考える必要があります。ボタンを有効にしているだけの場合は、OKです。もう一度設定しても何も変わりません。いくつかのイベントを一度しか動作させたくない場合は、 "on.once"を使用する必要があります。 –

関連する問題