1

KoGridのフィルターをカスタマイズして、「from-to」ロジックに基づいて日付データで列をフィルター処理できるようにしようとしています (フィルターを使用した KoGrid の例は、ここにあります)。私が望んでいたのは、適切なフィルター フィールドをクリックしたときに、Datepicker を使用した From と To の入力を含むダイアログを表示することです。

var vm = {
            filterInfo: ko.observable(),
            myObsArray: arr
        };
        ko.applyBindings(vm); 
...
$("div.kgheadercell.col5").on("click", "input", function (event) {               
   $("#popup").dialog("open");
});

This however seems to be not working properly, i.e. the dialog is not being displayed once I click on the text field. However, if I try to input the last bit of the code in Chrome's console, the handler is correctly bound and the dialog appears once I click on the text field.

However, if I try

$("body").on("click", "input", function (event) {               
 $("#popup").dialog("open");
});

this successfully adds handler as I'm able to see the dialog when I click on any (obviously) text field.

Is there something happening after this code so that it removes or changes the handler?

4

1 に答える 1

1

KoGrid は内部でテンプレートを使用してグリッドのレイアウトを管理します。次のいずれかが考えられます。

  • 「クリック」ハンドラーをヘッダー フィールドにアタッチしようとしている時点で、グリッドのレンダリングが完了していません。
  • ヘッダーのテンプレートが再レンダリングされ、クリック ハンドラーが効果的に削除されました

オプションとして、カスタム ヘッダー テンプレートを使用することができます。これは KoGrid ではまだ文書化されていませんが、機能はあります。フィルター ボックスとして使用される要素でクリック バインディングを<input>使用し、その値を手動で設定できます。

http://jsfiddle.net/ericbarnard/hCQ7r/1/

doSomethingフィルターをクリックして呼び出されるviewModelの関数をどのように配線したかを見てください<input>(フィルター行を開いた後)

于 2012-04-17T16:50:11.503 に答える