2017-04-03 29 views
0

IM試圖讓metric_nme列的文本值,如果這是等於「賬戶審計」隱藏更新按鈕...獲得劍道列文本值

沒有人知道我怎樣才能得到的值劍道網格中的列?

這裏,如果我的代碼...

$("#assessmentGrid").kendoGrid({ 
 
     dataSource: gridDS, 
 
     navigatable: true, 
 
     noRecords: { 
 
      template: "No assessments were found" 
 
     }, 
 
     filterable: true, 
 
     sortable: { 
 
      mode: 'single', 
 
      allowUnsort: false 
 
     }, 
 
     columns: [ 
 
        { field: 'assessment_pk', hidden: true }, 
 
        { field: 'role_fk', hidden: true }, 
 
        { field: 'role_nme', title: 'Role', width: 120 }, 
 
        { field: 'metric_fk', hidden: true }, 
 
        { field: 'assess_dte', hidden: true }, 
 
        { 
 
         field: 'metric_nme', title: 'Metric', width: 150, 
 
         validation: { 
 
          metric_nme_validation: function (input) { 
 
           if (dataItem[metric_nme] = 'Accounts Audit') { 
 
            // attributes: { 'class': 'k-grid-update' }. 
 
            $("#k-grid-update").data("kendoGrid").visible = false; 
 
           } 
 
          } 
 
         } 
 
         
 
        }, 
 
        { field: 'assess_val', title: 'Score', width: 80, template: "#= (returnUnitMetricID(metric_fk) == 2) ? parseInteger(assess_val, 10) : assess_val #", attributes: { 'style': 'text-align: right' } }, 
 
        { field: 'adjust_val', title: 'Manager Score', width: 100, template: "#= (returnUnitMetricID(metric_fk) == 2) ? parseInteger(adjust_val, 10) : adjust_val #", attributes: { 'style': 'text-align: right' } }, 
 
        { field: 'adjust_by', title: 'Adjusted By', width: 120 }, 
 
        { field: 'comment_txt', title: 'Comment', hidden: true }, 
 
        { field: 'rating_cde', title: 'Rating', width: 95 }, 
 
        { field: 'adjusted_fk', hidden: true }, 
 
        { field: 'pct_to_goal', title: '% to Goal', width: 100, template: '#=kendo.format("{0:p}", pct_to_goal/100)#', attributes: { 'style': 'text-align: right' } }, 
 
        { field: 'lastupdate_by', title: 'Last Update By', width: 100 }, 
 
        { field: 'lastupdate_on', title: 'Last Update On', width: 130, template: "#= (lastupdate_on == null) ? '' : kendo.toString(kendo.parseDate(lastupdate_on, 'yyyy-MM-dd'), 'MM/dd/yyyy H:mm:ss') #" }, 
 
        { 
 
         command: { 
 
          text: "Update", 
 
          click: updateScore, 
 

 
         }, title: " ", width: "60", 
 
         attributes: { 'class': 'k-grid-update' } 
 
        } 
 
     ], 
 
    }).find("table").on("keydown", onGridKeydown); 
 
    
 
    function updateScore(e) { 
 
    e.preventDefault(e); 
 
    clearWindowPopUpFields(); 
 
    $(".k-window").css('height', '420px'); 
 

 
    $(".alert").hide(); 
 

 
    var dataItem = this.dataItem($(e.currentTarget).closest("tr")); 
 

 
    var assestmentDate = new Date(dataItem.assess_dte); 
 
    $("#lbAssessmentDateRO").text($("#txtPeriod").val()); 
 

 
    $('#lblMetric').text(dataItem.metric_nme); 
 
    $('#lblRole').text(dataItem.role_nme); 
 
    metricFk = dataItem.metric_fk; 
 
    $('#txtAssociate').text($('#cbAssociate').data("kendoComboBox").text()); 
 
    switchScoreTypeControl(returnUnitMetricID(dataItem.metric_fk)); 
 

 
    if (dataItem.assessment_pk == null) { 
 
     addScorePopUp(dataItem); 
 
    } else { 
 
     updateScorePopUp(dataItem); 
 
    } 
 
}

+0

請回答... – omid

+0

你想隱藏的添加/編輯的行整列或只是一個值。你能描述一下流量和期望的輸出嗎? – Oskar

+0

我只需要獲取網格加載時的列值,並將其與「帳戶審計」文本進行比較,如果這是真的,我想隱藏更新按鈕... – omid

回答

0

可以使用visible參數:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.command.visible

下面是一個例子:

http://dojo.telerik.com/ACopA

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <base href="http://demos.telerik.com/kendo-ui/grid/custom-command"> 
 
    <style> 
 
    html { 
 
     font-size: 14px; 
 
     font-family: Arial, Helvetica, sans-serif; 
 
    } 
 
    </style> 
 
    <title></title> 
 
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.common-material.min.css" /> 
 
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.material.min.css" /> 
 
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.1.223/styles/kendo.material.mobile.min.css" /> 
 

 
    <script src="https://kendo.cdn.telerik.com/2017.1.223/js/jquery.min.js"></script> 
 
    <script src="https://kendo.cdn.telerik.com/2017.1.223/js/kendo.all.min.js"></script> 
 
</head> 
 

 
<body> 
 
    <script src="../content/shared/js/people.js"></script> 
 

 
    <div id="example"> 
 
    <div id="grid"></div> 
 

 
    <div id="details"></div> 
 

 
    <script> 
 
     var wnd, 
 
     detailsTemplate; 
 

 
     $(document).ready(function() { 
 

 
     var grid = $("#grid").kendoGrid({ 
 
      dataSource: { 
 
      pageSize: 20, 
 
      data: createRandomData(50) 
 
      }, 
 
      pageable: true, 
 
      height: 550, 
 
      columns: [{ 
 
       field: "FirstName", 
 
       title: "First Name", 
 
       width: "140px" 
 
      }, 
 
      { 
 
       field: "LastName", 
 
       title: "Last Name", 
 
       width: "140px" 
 
      }, 
 
      { 
 
       field: "Title" 
 
      }, 
 
      { 
 
       command: [{ 
 
       text: "View Details", 
 
       click: showDetails, 
 
       visible: function(dataItem) { 
 
        return dataItem.LastName.charAt(0) !== "D" 
 
       } 
 
       }] 
 
      } 
 
      ] 
 
     }).data("kendoGrid"); 
 

 
     wnd = $("#details") 
 
      .kendoWindow({ 
 
      title: "Customer Details", 
 
      modal: true, 
 
      visible: false, 
 
      resizable: false, 
 
      width: 300 
 
      }).data("kendoWindow"); 
 

 
     detailsTemplate = kendo.template($("#template").html()); 
 
     }); 
 

 
     function showDetails(e) { 
 
     e.preventDefault(); 
 

 
     var dataItem = this.dataItem($(e.currentTarget).closest("tr")); 
 
     wnd.content(detailsTemplate(dataItem)); 
 
     wnd.center().open(); 
 
     } 
 
    </script> 
 

 
    <script type="text/x-kendo-template" id="template"> 
 
     <div id="details-container"> 
 
     <h2>#= FirstName # #= LastName #</h2> 
 
     <em>#= Title #</em> 
 
     <dl> 
 
      <dt>City: #= City #</dt> 
 
      <dt>Birth Date: #= kendo.toString(BirthDate, "MM/dd/yyyy") #</dt> 
 
     </dl> 
 
     </div> 
 
    </script> 
 

 
    <style type="text/css"> 
 
     #details-container { 
 
     padding: 10px; 
 
     } 
 
     
 
     #details-container h2 { 
 
     margin: 0; 
 
     } 
 
     
 
     #details-container em { 
 
     color: #8c8c8c; 
 
     } 
 
     
 
     #details-container dt { 
 
     margin: 0; 
 
     display: inline; 
 
     } 
 
    </style> 
 
    </div> 
 

 

 
</body> 
 

 
</html>