排序:模板列表中,在需要排序的表头加上下面代码,但要注意script的data-params参数里的dataName必须填写列表的唯一的标识值,用于存放列表缓存的名称,同理table里的 data-name="articleCatData" data-tplid="list-tpl"也是必须填写,dataName与data-name的值必须是相同的
~~~
<div class="order-box">
<a href="javascript:;" class="sort" data-filed="title" data-asc="true"><i class="iconfont" ></i></a>
<a href="javascript:;" class="sort down" data-filed="title"><i class="iconfont"></i></a>
</div>
~~~
~~~
<script id="list-tpl" type="text/html" data-params='{"url":"/php/data.php","dataName":"articleCatData","pageid":"#page","tableWidth":"2200px"}'>
<table id="example" class="layui-table lay-even" data-name="articleCatData" data-tplid="list-tpl">
<thead>
<tr>
<th width="30"><input type="checkbox" id="checkall" data-name="checkbox" lay-filter="check" lay-skin="primary"></th>
<th width="60">序号</th>
<th>标题
<div class="order-box">
<a href="javascript:;" class="sort" data-filed="title" data-asc="true"><i class="iconfont" ></i></a>
<a href="javascript:;" class="sort down" data-filed="title"><i class="iconfont"></i></a>
</div>
</th>
<th>连接</th>
<th width="70">排序</th>
<th width="80">审核</th>
<th width="152">操作</th>
</tr>
</thead>
<tbody>
{{# layui.each(d.list, function(index, item){ }}
<tr>
<td><input type="checkbox" name="checkbox" value="{{ item.id}}" lay-skin="primary"></td>
<td>{{ item.id}}</td>
<td>{{ item.title}}</td>
<td>{{ item.url}}</td>
<td><input type="text" class="layui-input ajax-blur" name="order" value="{{ item.id}}" data-params='{"url":"/php/test.php","data":"id=1&name=paco","loading":"false"}'> </td>
<td><input type="checkbox" name="switch" lay-skin="switch" lay-text="已审|未审" {{#if (item.switch){ }}checked="checked" {{# } }} lay-filter="ajax" data-params='{"url":"/php/test.php","confirm":"true","data":"id={{ item.id}}&name=paco","complete":"test"}'> </td>
<td>
<button class="layui-btn layui-btn-mini modal-iframe" data-params='{"content": "article-add.html", "title": "{{item.title}}","full":"true"}'>
<i class="iconfont"></i>编辑
</button>
<button class="layui-btn layui-btn-mini layui-btn-danger ajax" data-params='{"url": "/php/test.php","confirm":"true","data":"id=1&name=ni"}'>
<i class="iconfont"></i>删除
</button></td>
</td>
</tr>
{{# }); }}
</tbody>
</table>
</script>
~~~