简体   繁体   English

Kendo UI网格,添加列和列总和值

[英]Kendo UI Grid, Add columns and columns sum values

I'm working with the Kendo Grid tool. 我正在使用Kendo Grid工具。 I have a data source which contains values ​​of an object and in this object exists another one. 我有一个数据源,其中包含一个对象的值,并且在该对象中存在另一个对象。 Is like two array, one inside the another one. 就像两个数组,一个在另一个里面。

$("#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"}
     ],
});

How should I create the columns, for data that are in the array into another array? 我应该如何创建列,以便将数组中的数据添加到另一个数组中? and how to sum columns and display the total in another column of the grid. 以及如何对列求和并在网格的另一列中显示总计。

You should probably check into calculated properties, in this case CantidadConsolidar might be a calculated field. 您可能应该检查计算出的属性,在这种情况下,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:{
        ...
    },
  }
}

}); });

Also, check DataSource Aggregates to display a sum of the values un a certain column of your grid. 另外,选中“ 数据源聚合”以显示网格某列中的值之和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM