0

我正在使用剑道网格工具。我有一个数据源,其中包含一个对象的值,并且在这个对象中存在另一个。就像两个数组,一个在另一个数组中。

$("#PedidoConsolidadoGrid").kendoGrid({
    dataSource: {
        data: mData,
        schema: {
            model: { // define the model of the data source. Required for validation and property types.
                id: "CodigoArticulo",
                fields: {
                    //CodigoPedido: { editable: false },
                    CodigoArticulo: { editable: false },
                    FechaPedido: { editable: false },
                    CantidadExistencias: { editable: false },
                    DescripcionArticulo: { editable: false },
                    CantidadConsolidar: {
                        editable: true, 
                        type: "number", 
                        validation: { required: true, min: 0, max: 9999 },
                    },
                }
            }
        },
        pageSize: 11
    },
    scrollable: true,
    pageable: true,
    editable: {
        mode: "inline", // mode can be incell/inline/popup with Q1 '12 Beta Release of Kendo UI
        confirmation: false // the confirmation message for destroy command
    }, // enable editing
    selectable: "single",
    pageable: {
        numeric: true,
        previousNext: true,
        refresh: true,
        buttonCount: 5,
        messages: {
            display: "Mostrando {0}-{1} de {2}",
            empty: "No hay datos para mostrar",
            page: "Enter page",
            of: "de {0}",
            itemsPerPage: "Pedidos por página",
            first: "Primera página",
            last: "Última página",
            next: "Siguiente",
            previous: "Anterior",
            refresh: "Refrescar"
        }
     },
     columns: [
         //{ field: "CodigoPedido", title: "Código del Pedido", width: "150px" },
         { field: "CodigoArticulo", title: mData[0].CodigoArticulo , width: "150px" },
         { field: "DescripcionArticulo", title: "Articulo", width: "200px" },
         { field: "FechaPedido", title: "Fecha Pedido", width: "150px", template: '#= kendo.toString( toDate(FechaPedido), "dd/MM/yyyy" ) #' },
         { field: "CantidadConsolidar", title: "Total Pedido", width: "120px", },
         { field: "CantidadExistencias", title: "Total Existencia", width: "120px" },
         { command: "edit", text: "Editar"}
     ],
});

我应该如何为数组中的数据创建列到另一个数组中?以及如何对列求和并在网格的另一列中显示总计。

4

1 回答 1

0

您可能应该检查计算属性,在这种情况下 CantidadConsolidar 可能是一个计算字段。

dataSource = new kendo.data.DataSource({
data: [
  { first: "John", last: "Doe" }, 
  { first: "Jane", last: "Doe" }
],
schema: {
  model: {
    // Calculated field
    fullName: function() {
      return this.get("first") + " " + this.get("last");
    }
    fields:{
        ...
    },
  }
}

});

此外,检查DataSource Aggregates以显示网格某一列的值的总和。

于 2014-01-15T15:06:52.957 回答