将JSON绑定到kendo网格JavaScript

时间:2013-04-10 22:51:50

标签: json binding grid kendo-ui

帮我修复两天前运行完美的代码。我不知道我有什么想法,但现在,网格只是空的,你能帮我一些忙吗?请。

$("#grid").kendoGrid({
       sortable: true,
       groupable: true,
       scrollable: true,
       height: "300px",
       pageable: {
         pageSizes: 9
                 },
       dataSource: {
         transport: {
             read: {
                url: "http://localhost/pharmacypoints/api/Productos/getSinFiltro",
                    dataType: "Json"
                              }
             }
                },
    Columns:  [
              { field: "Codigo",
                tittle: "Codigo"
              }, 
      { field: "Descripcion", 
        tittle: "Descripcion" 
      }, 
      { field: "Familia", 
        tittle: "Familia"
      }, 
      { field: "Laboratorio",
        title: "Laboratorio"
      }, 
      { field: "Clasificacion",
        tittle: "Clasificacion"
      }]

                        });

数据库结果如下:

[{"Codigo":"6140","Producto":"CIPROXINA FA 200ML 400MG","Familia":"ANTIBIOTICO 10","Clasificacion":"CONTROLADOS","Laboratorio":"BAYER DE MEXICO, SA DE CV"}, and more objects

1 个答案:

答案 0 :(得分:2)

两个小问题:

  1. Columns必须为小写。
  2. 它是title而不是tittle
  3. 试试这个:

    $("#grid").kendoGrid({
        sortable  : true,
        groupable : true,
        scrollable: true,
        height    : "300px",
        pageable  : {
            pageSizes: 9
        },
        dataSource: {
            transport: {
                read: {
                    url     : "http://localhost/pharmacypoints/api/Productos/getSinFiltro",
                    dataType: "Json"
                }
            }
        },
        columns   : [
            { field: "Codigo", title: "Codigo" },
            { field: "Descripcion", title: "Descripcion" },
            { field: "Familia", title: "Familia" },
            { field: "Laboratorio", title: "Laboratorio" },
            { field: "Clasificacion", title: "Clasificacion" }
        ]
    });