2013-10-01 56 views
0

我有一个具有内网剑道UI网 - 巴顿在页脚

 var gridAwaitingForApproval = $("#gridAwaitingForApproval").kendoGrid({ 
      dataSource: dsAwaitingTimeSheets, 
      sortable: true, 
      pageable: true, 
      detailTemplate: kendo.template($("#awaiting-template").html()), 
      detailInit: detailInit, 
      dataBound: dataBound, 
      columns: [ 
       { 
        field: "Name", 
        title: "Name", 
        width: "120px" 
       }, 
       { 
        field: "Position", 
        title: "Position", 
        width: "120px" 
       }, 
       { 
        field: "Site", 
        width: "120px" 
       } 
      ] 
     }); 

     function dataBound() { 
      var grid = this; 

      //expand all detail rows 
      grid.tbody.find("tr.k-master-row").each(function() { 
       grid.expandRow($(this)); 
      }); 

      //remove hierarchy cells and column 
      $(".k-hierarchy-cell").remove(); 
      $(".k-hierarchy-col").remove(); 

     } 

     function detailInit(e) { 

      var detailRow = e.detailRow; 

      var grid = detailRow.find(".entries").kendoGrid({ 
       dataSource: 
       { 
        data: timeSheetEntries, 
        pageSize: 5, 
        filter: { field: "CandidateId", operator: "eq", value: e.data.CandidateId } 
       }, 
       columns: [ 
        { field: "CandidateId", title: "CandidateId", width: "56px" }, 
        { field: "Date", title: "Date", width: "56px" }, 
        { field: "MinutesWorked", title: "Minutes Worked", width: "56px" }, 
        { field: "MinutesBreak", title: "Minutes Break", width: "56px" }, 
        { field: "AbsenceDetails", title: "Absence Details", width: "56px" } 
       ] 
      }); 

现在剑道UI格,我需要把命令按钮在每个内部网格视图的页脚,所以我做了什么是追加在寻呼机的div

grid.find(".k-pager-info") 
       .append('<span class="approve" style="margin-left:2em;float:right;"><a class="btn-approve btn btn-primary btn-small">Approve</a></span>') 
       .delegate(".approve a", "click", function(e) { 
        console.debug(e); 
        alert("I NEED TO GET THE CandidateId IN HERE"); 
       }); 

现在,我的问题是,我怎么能从按钮的点击事件访问特定的内部网格上的数据?

.delegate(".approve a", "click", function(e) { 
         console.debug(e); 
         alert("NEED TO ACCESS DATA OF THE GRID like CandidateId"); 
        }); 

有没有解决方法如何做到这一点?请注意,我没有使用内置的工具栏,因为它不够灵活。

http://jsfiddle.net/lincx/BSQyd/79/

UPDATE:林现在在这里...

grid.find(".k-pager-info") 
       .append('<span class="approve" style="margin-left:2em;float:right;"><a class="btn-approve btn btn-primary btn-small">Approve</a></span>') 
       .delegate(".approve a", "click", function(e) { 

        var gridData = grid.data("kendoGrid"); 
        //var newrowdata = grid.dataItem(); 

        var selection = grid.select(); 
        console.debug(selection); 
        var rowData = gridData.dataItem(selection); // UNDEFINED 
        console.log(rowData.CandidateId);// UNDEFINED 
       }); 
+0

任何??真的需要把这个东西排除出去.. – xlinc

回答

1

var selection = grid.select();应该var selection = gridData.select();