Home  >  Article  >  Web Front-end  >  Detailed explanation of how jquery easyui implements formatted columns

Detailed explanation of how jquery easyui implements formatted columns

小云云
小云云Original
2017-12-31 15:38:241570browse

This article mainly introduces how jquery easyui implements formatted columns. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

Main frame page: The URL content clicked on the west menu will be loaded in the main interface area.


<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8"/>
  <title>主界面</title>
  <p th:include="/public/util::public"/>
  <p th:include="/public/util::jquery-easyui"/>
  <script type="text/javascript" th:src="(${@configApp.getStaticWeb()})+&#39;/cms/script/main/index.js&#39;"></script>
  <script type="text/javascript" th:src="(${@configApp.getStaticWeb()})+&#39;/cms/script/site/site-index.js&#39;"></script>  
</head>
<body class="easyui-layout">
  <p data-options="region:&#39;north&#39;,title:&#39;&#39;" style="height:80px;" id="north"></p>
  <p data-options="region:&#39;west&#39;,title:&#39;系统功能区&#39;,split:true" style="width:200px;">
    <ul class="easyui-tree" id="menu"></ul>
  </p>
  <p data-options="region:&#39;center&#39;,title:&#39;主界面区&#39;" style="padding:5px;" id="center"></p>
</body>
</html>

At this time, easy-ui has been loaded on the main page The scripts and CSS do not need to be loaded in each area page. Even if they are loaded, they will be removed.

I initially added the formatting function to the datagrid page, but it had no effect. It always reported that the formatIsvalid function could not be found. .


<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8"/>
  <title>站点列表页面</title>
  <script type="text/javascript">
  function formatIsvalid(val,row){
    return val==&#39;1&#39;?&#39;是&#39;:&#39;否&#39;;
  }
  </script>
</head>
<body>
  <table id="site" title="站点列表" class="easyui-datagrid" th:url="@{/site/list}"
      toolbar="#siteToolbar" rownumbers="true" fitColumns="true" singleSelect="true">
    <thead>
      <tr>
        <th field="siteid" width="50">ID</th>
        <th field="sitename" width="50">名称</th>
        <th field="siteurl" width="50">网址</th>
        <th field="isvalid" width="50" formatter="formatIsvalid">是否有效</th>
        <th field="isdelete" width="50">是否可以删除</th>
        <th field="remark" width="50">备注</th>
        <th field="createtime" width="50">创建时间</th>
      </tr>
    </thead>
  </table>
  <p id="siteToolbar">
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newSite()">新增</a>
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editSite()">编辑</a>
    <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeSite()">删除</a>
  </p>
</body>
</html>

Solution: Put this formatting function into the main page and there will be no problem.

Related recommendations:

Example brief description of some usage of jQuery Easyui

Example detailed explanation of EasyUI's DataGrid adding operation buttons for each row of data

Detailed explanation of Datagrid in EasyUi control

The above is the detailed content of Detailed explanation of how jquery easyui implements formatted columns. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn