0

こんにちは、剣道グリッド テンプレート列を使用して関数に detailRow 参照を渡す方法はありますか?

これが私のトレイルです。

  function detailInit(e) {
            detailRow = e.detailRow;
          detailRow.find("#mygrid").kendoGrid({
                    dataSource: {
                        data: empModel,
                    },
                    columns: [
                    {
                        field: "empId",
                        title: "Emp ID",
                        template: '<a href="\\#" onclick="showEmpDetails(\'#= detailRow #\')">        }
                           ]
                 });
                });
4

1 に答える 1

0

取得したすべての detailRow をdetailInitグローバルに配置された配列に配置してから、このインデックスをクリック メソッド (または何らかのキー - 辞書である可能性があり、行には uid がある) に渡し、配列から行の詳細を読み取るメソッドを作成します。 /collection は、渡した ID に基づいて作成されます (理想的には、uid によってデータソースから行の詳細を直接読み取る必要があります。データを複製する必要はありません)。以下のコードを疑似コードとして参照してください。それを実行します。

var rows = new Array(); 

$('.clickable').click(function () {
     // get the id for your detail
     var detailId = this.attr('detailId');
     // pass it further
     showEmpDetails(detailId);
});

function detailInit(e) {
      detailRow = e.detailRow;
      // add roe to your (cache) collection
      rows[rows.legth] =  detailRow ;
      detailRow.find("#mygrid").kendoGrid({
            dataSource: {data: empModel},
            columns: [
                {
                    field: "empId",
                    title: "Emp ID",
                    // add attribute onto your a tag
                    template: '<a href="\\#" detailId = "#= rows.legth #" class="clickable">' 
                }
                      ]
             });
});

function showEmpDetails(id) {
     // read from your collection and do what you need
     console.log(rows[id]);
}
于 2013-09-16T16:26:32.343 に答える