CakePHP Bootstrap-表问题

CakePHP Bootstrap-tables trouble

我在使用 CakePHP 序列化和 bootstrap 表时遇到了一些问题。 我已经加载了所有 .js。 我认为 bootstrap-tables 不 reconize { "despesas":[.json 前面 有人可以帮助我吗?

我的route.php

//code    
Router::extensions(['json']);
//code

我的DespesasController.php函数

//code
       public function test()
    {
        $this->paginate = [
            'contain' => ['Lojas', 'DespesaTipos'],
            'limit' => '1000000000'
        ];
        $this->set('despesas', $this->paginate($this->Despesas));
        $this->set('_serialize', ['despesas']);
    } 
//code

test.ctp

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.css">



<table id="table"></table>

<!-- Latest compiled and minified JavaScript -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>

<!-- Latest compiled and minified Locales -->
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/locale/bootstrap-table-pt-BR.min.js"></script>
<script type="text/javascript">
  $('#table').bootstrapTable({
    url: 'test.json',
    columns: [{
        field: 'id',
        title: 'Item ID'
    }, {
        field: 'descricao',
        title: 'Item Name'
    }, {
        field: 'valor',
        title: 'Item Price'
    }, ]
});
</script>

test.json

{
    "despesas": [
        {
            "id": 1,
            "data": "2015-01-02T00:00:00-0200",
            "descricao": "INTERNET TRIBUNA BAIRROS (50%)",
            "valor": 1503,
            "loja_id": 1,
            "despesa_tipo_id": 1,
            "obs": "",
            "created": "2015-12-10T00:00:00-0200",
            "modified": "2015-08-05T00:00:00-0300",
            "criado_por": "Kelvin Primo",
            "modificado_por": "Deise"
        },

当我在浏览器上打开它时 returns。

No matching records found

在您创建 table 之前加载您的 json 数据,然后您可以将它传递到 table,它喜欢它。

<script type="text/javascript">    
$(function () {
  $.getJSON( "test.json", function(data) {
    $('#table').bootstrapTable({
      data: data.despesas,
      columns: [{
        field: 'id',
        title: 'Item ID'
      }, {
        field: 'descricao',
        title: 'Item Name'
      }, {
        field: 'valor',
        title: 'Item Price'
      }]
    });
  });
});
</script>