固定操作列表格模板

<div class="flex">
  <div class="overflow-x-auto" style="flex: 1;">
    <div class="flex flex-nowrap" style="min-width: max-content;">
      <!-- 可拖拽列表内容 -->
    </div>
  </div>

  <div class="min-w-[296px] bg-bg-1" style="flex-shrink: 0;">
    <!-- 操作列内容 -->
  </div>
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用FreeMarker(ftl)模板和layui设置固定之后,如果按钮不展示,可能也是因为按钮被隐藏在了固定的后面,导致无法显示出来。这个问题同样可以通过调整固定和非固定的顺序来解决。 具体的实现方法可以参考以下代码: ```html <table class="layui-table" lay-size="sm"> <colgroup> <col width="100"> <col width="150"> <col> <col width="200"> <col width="200"> <col width="200"> <col width="100"> </colgroup> <thead> <tr> <th rowspan="2">ID</th> <th rowspan="2">用户名</th> <th rowspan="2">性别</th> <th colspan="3">联系方式</th> <th rowspan="2">操作</th> </tr> <tr> <th>手机</th> <th>邮箱</th> <th>地址</th> </tr> </thead> <tbody> <#list userList as user> <tr> <td>${user.id}</td> <td>${user.username}</td> <td>${user.sex}</td> <td>${user.phone}</td> <td>${user.email}</td> <td>${user.address}</td> <td> <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button> <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</button> </td> </tr> </#list> </tbody> </table> ``` ```js layui.use(['table', 'form'], function() { var table = layui.table; // 渲染表格 table.render({ elem: '.layui-table', cols: [[ {field: 'id', title: 'ID', fixed: 'left', width: 100}, {field: 'username', title: '用户名', fixed: 'left', width: 150}, {field: 'sex', title: '性别', width: 100}, {field: 'phone', title: '手机', width: 200}, {field: 'email', title: '邮箱', width: 200}, {field: 'address', title: '地址', width: 200}, {fixed: 'right', title: '操作', toolbar: '#toolbar', width: 100}, ]], data: [ // 数据 ], }); // 监听窗口大小变化 $(window).on('resize', function() { var width = $('.layui-form').width(); $('.layui-table-box').css('width', width + 'px'); }).resize(); // 监听工具条按钮点击事件 table.on('toolbar', function(obj) { switch(obj.event) { case 'add': // 添加操作 break; case 'delete': // 删除操作 break; } }); }); ``` 在这个例子中,使用了FreeMarker的语法来生成表格中的数据行,同时将操作设置为固定,并且将其放在了的最后面,这样就可以保证操作按钮可以正常显示了。同时,在监听工具条按钮点击事件时,需要根据按钮的event属性来判断是哪个按钮被点击了,然后执行相应的操作

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值