在jquery数据表中跳过打印数组的第一个值

时间:2017-12-08 11:33:48

标签: jquery datatables

这是来自api的回复

{"recordsTotal":13,"data":[[13,"wretwer","rgsdfg","sdfgsd",null],[12,"heyh","gffsf","sfgsdf",null],[11,"sdfgwt","hdgdhsf","sfgsf",null],[10,"ethgs","fgsdfgsfd","dfsgdf",null],[9,"ertyyh","dgfsfg","sdfgs",null],[8,"yuyet","ertg","hdghd",null],[7,"dfgs","wtwr","sdfg",null],[6,"tyueyt","etyetye","erty",null],[5,"qerqe","qwer","qwerqwer",null],[4,"d","d","ggsss",null],[3,"asdf","asdf","asdf",null],[2,"asdfasd","asdfasdf","asdfadsf",null],[1,"test","asdf","34asdfasdfasdfasdfasdf",null]]}

我想跳过打印13或12 ....的数组的第一个值。

这是我到目前为止所得到的

'use strict';
$(document).ready(function() {
    $("#appartment-table").DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "/datatable/apartments",
        "columns": [
                    null,
                    null,
                    null,
                    null, 
            {"mRender": function ( data, type, row ) {
                            return '<a href="apartments/'+row[0]+'/edit">Edit</a>';}
                    }         
     ]
    });
});

1 个答案:

答案 0 :(得分:2)

您可以选择数组索引显示的列:

generate

将跳过数组中的第一个元素,13,12 ...请记住相应地调整columns: [ { data: 1 }, { data: 2 }, { data: 3 }, { data: 4, render: function ( data, type, row ) { return '<a href="apartments/'+row[0]+'/edit">Edit</a>'; } } ] 中的列(如果您使用静态thead而不是让DT使用{{1}创建它})