将图标添加到django模板表中的特定行

时间:2017-01-26 18:40:39

标签: python css django icons

我正在研究python Django模板,其中我有一个表格,其列为 id,因子A,因子B,因子C 。 id,因子A,因子B和因子C的值分别为79,0.56,1.1,1.3。

enter image description here

html模板的代码如下:

<?php

if($_SERVER['REQUEST_METHOD']=='POST'){
    $Phone_Name = $_POST['Phone_Name'];
    $Customer = $_POST['Customer_non','utf8_decode'];
    $IMEI = $_POST['IMEI'];
    $Mobile = $_POST['Mobile'];
    $Status = $_POST['Status'];
    $Fault = $_POST['Fault'];
    $custfault = $_POST['custfault'];
    $max_Cost = $_POST['max_Cost'];
    $accesories = $_POST['accesories'];
    require_once('dbConnect.php');
    $sql = "INSERT INTO phone_in (Phone_Name,Customer_non,IMEI,Mobile,Status,Fault,max_Cost,accesories,custfault) VALUES ('$Phone_Name','$Customer','$IMEI','$Mobile','$Status','$Fault','$max_Cost','$accesories','$custfault')";
    if(mysqli_query($con,$sql)) {
        echo "Successfully Registered";
    }else {
        echo "Could not register";
    }
} else {   
    echo 'error';
}

对于 aggregateData.Open 为true的行,我想为此类似的内容添加一个可点击图标。 enter image description here

有人可以建议我如何实现这一目标。

1 个答案:

答案 0 :(得分:1)

试试这个。

<table class="table table-bordered">
  <thead>
    <tr>
      <th class="text-center">id</th>
      <th class="text-center">Factor A</th>
      <th class="text-center">Factor B</th>
      <th class="text-center">Factor C</th>
    </tr>
  </thead>
  <tbody >
    <tr ng-class="{'info':aggregateData.Mode, 'closed':!aggregateData.Open}">
      <td class="text-center">{{aggregateData.id}}</td>
      <td class="text-center">{{aggregateData.factor_a}}</td>
      <td class="text-center">{{aggregateData.factor_b}}</td>
      <td class="text-center">{{aggregateData.factor_c}}</td>
      {% if aggregateData.open == True %}
        <td class="text-center">
          <a href="https://www.google.co.in">
            <img src="/path_toicon.png">    
          </a>
        </td>
      {% endif %}
    </tr>
  </tbody>
</table>