Layui implements the method of adding a row by clicking a button

Release: 2020-06-12 17:55:32
forward
3396 people have browsed it

Layui implements the method of adding a row by clicking a button

1. Use ajax request to retrieve the data and store it in a variable, and assign the variable to the data of the table

  var organData = [];
  $.ajax({
        url: baseUrl+'/org/getSysOrgList'
        ,type:"POST"
        ,async:false
        ,dataType:"json"
        , success: function(result){
            organData=result;
        }
  });
Copy after login

2. Pass the data through the data method

table.render({
        elem: '#organ-manage-list'
        ,data:organData
        ,method:'POST'
        ,cols: [[
         {field: 'orgCode', width: 100, title: '组织编码', sort: true}
        ,{field: 'orgName', title: '组织名称', width: 200}
        ,{field: 'pOrgCode', title: '上级行政组织', width: 100}
        ,{field: 'orgModal', title: '组织形态', width: 100}
        ,{field: 'isSelfOrg', title: '是否核算组织', width: 100}
        ,{field: 'status', title: '启/停用', width: 100}
        ,{field: 'updTime', title: '更新时间', width: 200}
        ,{title: '操作',align:'center', fixed: 'right', toolbar: '#table-organ-operator'}
        ]]
        ,page: true
        ,limit: 10
        ,height: 'full-220'
        ,done: function(res, curr, count){
              //如果是异步请求数据方式,res即为你接口返回的信息。
              //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度
                sessionStorage.setItem("countTemp",count);
              }
        ,text: '对不起,加载出现异常!'
  });
Copy after login

For more layui knowledge, please pay attention to the PHP Chinese websitelayuitutorial column

The above is the detailed content of Layui implements the method of adding a row by clicking a button. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template