2017-05-19 73 views
0

我有一個問題,我甚至有一個想法,從哪裏開始尋找.. 所以我有一個網格和一列類型的收據。值是數字。我如何用有意義的值替換它們(如果type爲'0',那麼我需要顯示'CASH')。什麼是最明智的做法呢?更換劍道網格中的值

代碼:

<?php 
require_once(__DIR__ . '/localization/taxesLocalization.php'); 
?> 

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8"> 
     <title><?php echo $taxes ?></title> 
     <link rel="stylesheet" href="styles/kendo.common-material.min.css" /> 
     <link rel="stylesheet" href="styles/kendo.material.min.css" /> 
     <link rel="stylesheet" href="css/custom_style.css"> 
     <link rel="stylesheet" href="HtmlTemplates/notifications.php"> 
     <script src="js/jquery.min.js"></script> 
     <script src="js/kendo.all.min.js"></script> 
     <script src="js/devices.js"></script> 
     <script src="js/functions.js"></script> 
     <script src="js/FCM.js"></script> 
     <script src="js/functions/confirm_window.js"></script> 
     <script src="js/MessageTypes/message_types.js"></script> 
     <script src="js/functions/show_notification.js"></script> 
     <script src="js/taxes_scripts/constants.js"></script> 
     <script src="js/taxes_scripts/functions.js"></script> 
     <script src="js/functions/duplicates_check.js"></script> 
     <script src="js/taxes_scripts/services.js"></script> 
    </head> 
    <body> 
     <nav> 
      <div id="toolbar"></div> 
      <?php include "navmenu.php"; ?> 
     </nav> 
     <span id="popupNotification"></span> 
     <br> 
     <div class="" style="width: 100%;"> 
      <div> 
       <div id="device_container"> 
        <label for="devices" ><b><?php echo $devices ?></b></label> 
        <input id="device-report" style="width: 270px" /> 
       </div> 
      </div> 
      <br> 
      <div id="gridSession"></div> 
       <div id="grid"></div> 
     </div> 
    </body> 
</html> 

<script> 
    var device_ID = 510; 


    const X_SESSION = "./services/ReportsServices/getXSessionInfo.php?device_ID="; 
    $(document).ready(function() { 

     var dataSource = new kendo.data.DataSource({ 
      transport: { 
       read: { 
        url: X_SESSION + device_ID, 
        dataType: "json" 
       } 
      }, 
      schema: { 
       data: "data", 
       model: { 
        id: "id", 
        fields: { 
         sequence: {}, 
         datestart: {}, 
         total: {}, 
         type: {}, 
         receipt_count: {}, 
         from_ticket: {}, 
         to_ticket: {}, 
         date_start: {}, 
         date_end: {} 
        } 
       } 
      } 
     }); 
     var grid = $("#grid").kendoGrid({ 
      dataSource: dataSource, 
      navigatable: true, 
      scrollable: true, 
      resizable: true, 
      sortable: true, 
      filterable: false, 
      height: $(document).height() - 120, 
      columns: [ 
       {field: "sequence", title: "Slijed"}, 
       {field: "datestart", title: "Početak sesije"}, 
       {field: "total", title: "Ukupno na računu"}, 
       {field: "type", title: "Način plačanja "}, 
       {field: "receipt_count", title: "Broj računa"}, 
       {field: "from_ticket", title: "Od kartice"}, 
       {field: "to_ticket", title: "Do kartice"}, 
       {field: "date_start", title: "Datum prvog računa"}, 
       {field: "date_end", title: "Datum zadnjeg računa"} 

      ] 
     }).data("kendoGrid"); 

     $("#device-report").kendoComboBox(
      ); 

    }); 
</script> 

回答

0

您可以在網格列,這將檢查type值,並更新相應的列字段使用template

{field: "type", title: "Način plačanja", template: "#if (type == 0) {# CASH #} else {# Another value #}#"} 

編輯

避風港之前在template列中沒有使用switch,但som像這樣的應該是非常接近:

+1

我會很樂意給你買一杯啤酒..銀行! – DraganK

+0

嘿它可能做到這一點與開關盒不知何故? – DraganK

+0

檢查更新...未經測試,但相當有信心它應該是關閉:) – Sandman