How to avodi the strike-through in the row content if the status is inactive?

笑着哭i 提交于 2020-04-30 06:29:13

问题


I have a problem to avoid the row content $row['filing_code_refer'] become the strike-through if the status is inactive, my coding show me the output below cannot avoid the $row['filing_code_refer'] become the strike-through.

Below is my coding:

 <?php 
   $folderData = mysqli_query($mysql_con,"SELECT * FROM filing_code_management");
    // $arr_sql5 = db_conn_select($folderData);
    // foreach ($arr_sql5 as $rs_sql5) {
    // $active = $rs_sql5['status'];
// }


   $folders_arr = array();
   while($row = mysqli_fetch_assoc($folderData)){
      $parentid = $row['parentid'];
      if($parentid == '0') $parentid = "#";

      $selected = false;$opened = false;
      if($row['id'] == 2){
         $selected = true;$opened = true;
      }
      $folders_arr[] = array(

         "id" => $row['id'],
         "parent" => $parentid,
         "text" => $row['name'] . ' ' . "<span id='category'>". $row['category']."</span>" . ' ' . "Rujuk Kod" .$row['filing_code_refer'],
         "category" => $row['category'],
         "filing_code_refer" => $row['filing_code_refer'],
         // "status" => $row['status'], // status 0 is inactive, status 1 is active
         "data" => array("status" => $row['status']) ,
         "state" => array("selected" => $selected,"opened"=>$opened) 

      );
   }

   ?> 

 <!-- Initialize jsTree -->
   <div id="folder_jstree" title=""></div>
   <!-- Store folder list in JSON format -->
   <textarea style="" id='txt_folderjsondata'><?= json_encode($folders_arr) ?></textarea>


<script style="text/javascript">
  $(document).ready(function() {
    var folder_jsondata = JSON.parse($('#txt_folderjsondata').val());

    $('#folder_jstree').jstree({
      'core': {
        'data': folder_jsondata,
        'multiple': false
      },
      'plugins': ['sort'],
      'sort': function(a, b) {
        return this.get_text(a).localeCompare(this.get_text(b), 'en', {
          numeric: true
        });
      }
    });

    var getColor = function(i) {
      if (i >= 100 && i <= 199) {
        return "blue";
      } else if (i >= 200 && i <= 299) {
        return "red";
      } else if (i >= 300 && i <= 399) {
        return "yellow";
      } else if (i >= 400 && i <= 499) {
        return "purple";
      } else if (i >= 500 && i <= 599) {
        return "green";
      } else {
        return "#000";
      }
    };



    var colorNodes = function(nodelist) {
        var getStrike = function(status) {
      if (status === "0") {
        return "line-through;";
      }  else {
        return "";
      }
    };
      var tree = $('#folder_jstree').jstree(true);
      nodelist.forEach(function(n) {
        tree.get_node(n.id).a_attr.style = "color:" + getColor(parseInt(n.text.substr(0, 3), 10))+ ";"+"text-decoration:" + getStrike(n.data.status);
        tree.redraw_node(n.id); //Redraw tree
        colorNodes(n.children); //Update leaf nodes
      });
    };

    $('#folder_jstree').bind('load_node.jstree', function(e, data) {
      var tree = $('#folder_jstree').jstree(true);
      colorNodes(tree.get_json());
    });


    $('#folder_jstree').bind('hover_node.jstree', function(e, data) {
      $("#" + data.node.id).attr("title", data.node.original.category);
    });

  });

</script>

This is my working JSfiddle : https://jsfiddle.net/ason5861_cs/3agdhkqf/3/

Actually, I want the output like below the picture can show filing_code_refer if the folder name status is inactive(0). If active will no show the filing_code_refer content.Hope someone can guide me how to solve it. Thanks.


回答1:


This element is deprecated in HTML 4 and XHTML 1, and obsoleted in HTML5. If semantically appropriate, i.e., if it represents deleted content, use instead. In all other cases use .



来源:https://stackoverflow.com/questions/61451896/how-to-avodi-the-strike-through-in-the-row-content-if-the-status-is-inactive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!