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()})+'/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"> <p data-options="region:'north',title:''" style="height:80px;" id="north"></p> <p data-options="region:'west',title:'系统功能区',split:true" style="width:200px;"> <ul class="easyui-tree" id="menu"></ul> </p> <p data-options="region:'center',title:'主界面区'" 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=='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> <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!