码迷,mamicode.com
首页 > 其他好文 > 详细

bootstrapTable sidePagination server出现No matching

时间:2018-12-11 17:17:57      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:boot   mount   price   server   paginati   UNC   tst   rds   ref   

bootstrapTable sidePagination server pagination true 出现No matching records found
对此纠结了一上午,首先百度、google,其实作者已经给出例子了,不仔细查看api和wiki怪不得别人哇!!!
作者例子:
http://issues.wenzhixin.net.cn/bootstrap-table/#options/server-side-pagination.html
从里面可以看到数据格式应该是:

{
  "total": 800,
  "rows": [
    {
      "id": 0,
      "name": "Item 0",
      "price": "$0"
    },
    {
      "id": 1,
      "name": "Item 1",
      "price": "$1"
    },
    {
      "id": 2,
      "name": "Item 2",
      "price": "$2"
    },
    {
      "id": 3,
      "name": "Item 3",
      "price": "$3"
    },
    {
      "id": 4,
      "name": "Item 4",
      "price": "$4"
    },
    {
      "id": 5,
      "name": "Item 5",
      "price": "$5"
    },
    {
      "id": 6,
      "name": "Item 6",
      "price": "$6"
    },
    {
      "id": 7,
      "name": "Item 7",
      "price": "$7"
    },
    {
      "id": 8,
      "name": "Item 8",
      "price": "$8"
    },
    {
      "id": 9,
      "name": "Item 9",
      "price": "$9"
    }
  ]
}

这种json格式,就可以了,前端就会有数据了!!!
client的不需要前面的total和rows

[
    {
        "id": 0,
        "name": "Item 0",
        "price": "$0",
        "amount": 3
    },
    {
        "id": 1,
        "name": "Item 1",
        "price": "$1",
        "amount": 4
    },
    {
        "id": 2,
        "name": "Item 2",
        "price": "$2",
        "amount": 8
    },
    {
        "id": 3,
        "name": "Item 3",
        "price": "$3",
        "amount": 2
    },
    {
        "id": 4,
        "name": "Item 4",
        "price": "$4",
        "amount": 90
    },
    {
        "id": 5,
        "name": "Item 5",
        "price": "$5",
        "amount": 2
    },
    {
        "id": 6,
        "name": "Item 6",
        "price": "$6",
        "amount": 3
    },
    {
        "id": 7,
        "name": "Item 7",
        "price": "$7",
        "amount": 7
    },
    {
        "id": 8,
        "name": "Item 8",
        "price": "$8",
        "amount": 39
    },
    {
        "id": 9,
        "name": "Item 9",
        "price": "$9",
        "amount": 78
    },
    {
        "id": 10,
        "name": "Item 10",
        "price": "$10",
        "amount": 30
    },
    {
        "id": 11,
        "name": "Item 11",
        "price": "$11",
        "amount": 32
    },
    {
        "id": 12,
        "name": "Item 12",
        "price": "$12",
        "amount": 12
    },
    {
        "id": 13,
        "name": "Item 13",
        "price": "$13",
        "amount": 76
    },
    {
        "id": 14,
        "name": "Item 14",
        "price": "$14",
        "amount": 10
    },
    {
        "id": 15,
        "name": "Item 15",
        "price": "$15",
        "amount": 9
    },
    {
        "id": 16,
        "name": "Item 16",
        "price": "$16",
        "amount": 8
    },
    {
        "id": 17,
        "name": "Item 17",
        "price": "$17",
        "amount": 1
    },
    {
        "id": 18,
        "name": "Item 18",
        "price": "$18",
        "amount": 99
    },
    {
        "id": 19,
        "name": "Item 19",
        "price": "$19",
        "amount": 100
    },
    {
        "id": 20,
        "name": "Item 20",
        "price": "$20",
        "amount": 109
    }
]

后端nodejs

var total = 300;//这一条要根据sql得到的count数才可以
db.sql(sql, function(err, results) {
                                if (err) {
                                    console.log("出现错误:", err);
                                    res.write("出现错误,请刷新后重试!");
                                    res.end();
                                } else {
                                    var send_arr = {};
                                    send_arr["total"] = total;
                                    send_arr["rows"] = results;
                                    res.json(send_arr);
                                }
                            })

bootstrapTable sidePagination server出现No matching

标签:boot   mount   price   server   paginati   UNC   tst   rds   ref   

原文地址:http://blog.51cto.com/314258/2328966

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!