• DataTables.js插入数据的两种方式


    一:采用数组的方式插入值 

    var tableData = [];
                var i = 0;
                var idxTable = 1;
                $.each(data, function (i, d) {
                    tableData.push([idxTable, d.stcd, d.stnm, d.ddz, d.ddcp, d.ckflz,d.normz,d.ttcp,d.actcp,d.z,d.w,d.inq,d.oz,d.outq,d.adjw,"","","查看"]);
                    idxTable++;
                });
                //所有数据添加到表格中
                thGridTable.fnClearTable(false);
                thGridTable.fnAddData(tableData);

    二:采用Json对象插入值,必须在创建的时候设置列名

    //创建表格
                var thGridTable = $('#' + tableName).dataTable({
                    "sScrollY": "320px",
                    "bPaginate": false,
                    "bLengthChange": false,
                    "bScrollCollapse": false,
                    "paging": false,
                    "ordering": false,
                    "bSort": false,
                    "info": false,
                    "bFilter": false,
                    "bJQueryUI": false,
                    "language": {
                        "lengthMenu": "每页 _MENU_ 条记录",
                        "zeroRecords": "没有找到记录",
                        "info": "共 _TOTAL_ 条记录",
                        "infoEmpty": "无记录",
                        "infoFiltered": "(从 _MAX_ 条记录过滤)"
                    },
                    "aoColumns": [
                        { "mData": "stcd" },
                        { "mData": "stcd" },
                        { "mData": "stnm" },
                        { "mData": "ddz" },
                        { "mData": "ddcp" },
                        { "mData": "ckflz" },
                        { "mData": "normz" },
                        { "mData": "ttcp" },
                        { "mData": "actcp" },
                        { "mData": "z" },
                        { "mData": "w" },
                        { "mData": "inq" },
                        { "mData": "oz" },
                        { "mData": "outq" },
                        { "mData": "adjw" },
                        { "mData": "ddcp" },
                        { "mData": "ddcp" },
                        { "mData": "ddcp" },
                    ]
                });
    //所有数据添加到表格中
                thGridTable.fnClearTable(false);
                thGridTable.fnAddData(data);
  • 相关阅读:
    二极管测试
    MOS开关速度
    STM8L PWM输出通道
    STM8Lpwm
    IAR 使用技巧
    java学习第十一天
    java学习第十天
    java学习第九天
    部分总结
    发现一篇好文,说的很详细,先收藏了。
  • 原文地址:https://www.cnblogs.com/coolsundy/p/4242788.html
Copyright © 2020-2023  润新知