更新 table 示例

This commit is contained in:
贤心
2022-08-24 11:27:31 +08:00
parent 3b3794dfb4
commit c4be812531
2 changed files with 28 additions and 12 deletions

View File

@@ -70,9 +70,9 @@
</div>
</script>
<table id="test" lay-filter="test"></table>
<table id="test"></table>
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.13/layui.js"></script>
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.7.6/layui.js"></script>
<script>
(function(off){
if(!off) return;
@@ -130,7 +130,7 @@ layui.use(['table', 'dropdown'], function(){
].join('')
//,className: '.demo-table-view'
//,size: 'lg'
//,size: 'sm'
//,skin: 'line'
//,loading: false
@@ -148,6 +148,7 @@ layui.use(['table', 'dropdown'], function(){
}]
//,escape: false
,editTrigger: 'dblclick'
//,cellMaxWidth: 320
,cols: !1 ? test_cols : [[
{type: 'checkbox', fixed: 'left'}
//,{type: 'numbers', fixed: 'left'}
@@ -155,7 +156,7 @@ layui.use(['table', 'dropdown'], function(){
,{field:'username', title:'用户名', width:120, edit: function(d){
return !d.LAY_DISABLED;
}, templet: '#usernameTpl'}
,{field:'email', minWidth: 160, title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, edit: 'text', templet: function(d){
,{field:'email', minWidth: 160, maxWidth: 320, title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, edit: 'text', templet: function(d){
return '<em>'+ layui.util.escape(d.email) +'</em>'
}}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true, escape: false}
@@ -453,6 +454,16 @@ layui.use(['table', 'dropdown'], function(){
update[field] = value;
obj.update(update, true); // 参数 true 为新版新增功能,详见文档
});
// 列拖拽宽度后的事件 -- v2.8.0 新增
table.on('colResized(test)', function(obj){
console.log(obj);
});
// 列拖拽宽度后的事件 -- v2.8.0 新增
table.on('colToggled(test)', function(obj){
console.log(obj);
});
});
</script>
</body>