weixin_33725272 2016-06-20 18:59 采纳率: 0%
浏览 23

限制数据表字段

I am using AJAX to source my datatables data. However, I am getting the error:

unknown parameter '0' for row 0, column 0

because my ajax response object has more fields than what I defined in my table's initialization. Is there a way I can limit or specify what parts of the ajax response go into my datatable? Here's my javascript:

$.ajax({
    type: "GET",
    url: "/api/admin/employees",
    success: function(data) {
        $('#eployees').DataTable({
                responsive: true,
                data: data,
                columns: [
                    { title: "Name" },
                    { title: "Position" },
                    { title: "Office" },
                    { title: "Extn." },
                    { title: "Start date" },
                    { title: "Salary" }
                ]
        });
    },
    error: function(data, status, res) {
        console.log('error...');
        console.log(res);
    }
});

Note - my data object contains 20 fields, but I only need the 6 that are defined below.

Can someone help? Thanks in advance!

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题