jquery easyui如何实现格式化列

2019-11-17,,,

本文主要介绍了jquery easyui如何实现格式化列 ,正好最近需要用到,分享给大家,也给自己留个笔记

主框架页面: 在主界面区会加载西区菜单点击的URL内容.

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

此时在主页面已经加载了easy-ui的脚本和CSS ,在各区页面就不必加载了,即使加载了也会被去掉.

我一开始在datagrid页面添加格式化函数,但是没有效果,始终报找不到formatIsvalid这个函数.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8"/>
  <title>站点列表页面</title>
  <script type="text/javascript">
  function formatIsvalid(val,row){
    return val=='1'?'是':'否';
  }
  </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>
  <div 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>
  </div>
</body>
</html>

解决办法:把这个格式化函数放到主页面中就没有问题了.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持北冥有鱼。

您可能感兴趣的文章:

  • 浅谈如何实现easyui的datebox格式化
  • 浅谈jQuery.easyui的datebox格式化时间
  • JQuery EasyUI 数字格式化处理示例
  • jquery EasyUI的formatter格式化函数代码

《jquery easyui如何实现格式化列.doc》

下载本文的Word格式文档,以方便收藏与打印。