jquery datatables: adding extra column

前端 未结 3 2002
轮回少年
轮回少年 2020-12-08 07:19

Scenario

I am using datatables (@version 1.9.4) for the first time to display data to the user. I succeed in retrieving the data via ajax and in bin

3条回答
  •  执笔经年
    2020-12-08 07:38

    You can define your columns in a different way like this

    "aoColumns": [
            null,
            null,
            null,
            null,
            null,
            { "mData": null }
        ]
    

    or this

    "aoColumnDefs":[
        {
            "aTargets":[5],
            "mData": null
        }
    ]
    

    Here some docs Columns

    Take a look at this DataTables AJAX source example - null data source for a column

    Note that prior to DataTables 1.9.2 mData was called mDataProp. The name change reflects the flexibility of this property and is consistent with the naming of mRender. If 'mDataProp' is given, then it will still be used by DataTables, as it automatically maps the old name to the new if required.

    Another solution/workaround could be adding that '5' parameter...

    For example adding extra "" to each row

    like this:

        [
            "IT",
            "10030",
            "VILLAREGGIA",
            "TO",
            "Torino",
            ""
        ],
        [
            "IT",
            "10030",
            "VISCHE",
            "TO",
            "Torino",
            ""
        ]
    

提交回复
热议问题