在数据表中添加按钮

时间:2017-06-01 07:49:26

标签: javascript html datatable

我正在尝试为数据表中的每一行添加一个按钮。目前,数据可以适当地显示在表格中。如果数据存在,我可以知道如何为“操作”添加编辑按钮吗?感谢

的index.html

 <table id="table1" class="table table-striped table-bordered" cellspacing="0" width="100%">
    <thead>
    <tr>
        <th>Name</th>
        <th>Email</th>
        <th>Phone</th>
        <th>Date of Birth</th>
        <th>Address</th>
         <th>Action</th>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
<script>
        app.view();
</script>

app.js

  var app = {
    view: function(){
        createDataTable("#table1",
        {
            "ajax": "/test/back-api/admin/packages",
            "columns": [
            {"data": "id"},
            {"data": "name"},
            {"data": "create_date"},     
            {"data": "currency"},    
            {"data": "description"} ,
            {"data": ""}, //adding edit button here 
                     ]                                      
        });
    }
}

matrix_table.js

var app = (
    var AppTable = function(){
        this.responsive = true;
        this.bJQueryUI = true;
        this.scrollX = true;
        this.height = "100px";
        this.display = "block";
        this.sPaginationType =  "full_numbers";
        this.sDom =  '<""l>t<"F"fp>';        

    };
}

var createDataTable = function(jqo, options){
    var m_options = new AppTable();       
    $.each(options, function(k, v){
    m_options[k] = v;
    });     
    var table = $(jqo).DataTable(m_options);
    return table;
};
$.fn.dataTable.ext.errMode = 'none';

0 个答案:

没有答案