DevExtreme:Spring Rest Api返回的对象未与dxDataGrid绑定

时间:2018-11-13 12:37:49

标签: datagrid devexpress devextreme

任何人都可以帮助我如何使用customstore将数据对象与DevExtreme的dxDataGrid绑定。

我的DTO就像:

[

数据:{...},   totalCount:100,   摘要:[10,20,30]

]

但是当我用dxDataGrid绑定数据时,它只是绑定数据,而不是totalCount。

2 个答案:

答案 0 :(得分:1)

我找到了解决我问题的方法。

library(tidyr)
fill(as.data.frame(x),x)[is.na(x),]
#[1] 5 4 4

我需要remoteOperations = true来绑定totalCount和从服务器获取的数据。

答案 1 :(得分:0)

您不需要发送 totalCount ,您必须使用摘要部分,而不是查看this sample

$("#gridContainer").dxDataGrid({
        dataSource: orders,
        keyExpr: "ID",
        showBorders: true,
        selection: {
            mode: "single"
        },
        columns: [{
                dataField: "OrderNumber",
                width: 130,
                caption: "Invoice Number"
            }, {
                dataField: "OrderDate",
                dataType: "date",
                width: 160
            }, 
            "Employee", {
                caption: "City",
                dataField: "CustomerStoreCity"
            }, {
                caption: "State",
                dataField: "CustomerStoreState"  
            }, {
                dataField: "SaleAmount",
                alignment: "right",
                format: "currency"
            }
        ],
        summary: {
            totalItems: [{
                column: "OrderNumber",
                summaryType: "count"
            }]
        }
    });

数据源

var orders = [{
    "ID" : 1,
    "OrderNumber" : 35703,
    "OrderDate" : "2014-04-10",
    "SaleAmount" : 11800,
    "Terms" : "15 Days",
    "TotalAmount" : 12175,
    "CustomerStoreState" : "California",
    "CustomerStoreCity" : "Los Angeles",
    "Employee" : "Harv Mudd"
}, {
    "ID" : 4,
    "OrderNumber" : 35711,
    "OrderDate" : "2014-01-12",
    "SaleAmount" : 16050,
    "Terms" : "15 Days",
    "TotalAmount" : 16550,
    "CustomerStoreState" : "California",
    "CustomerStoreCity" : "San Jose",
    "Employee" : "Jim Packard"
}....
]

对于custom summaries you can use this

summary: {
            totalItems: [{
                    name: "SelectedRowsSummary",
                    showInColumn: "SaleAmount",
                    displayFormat: "Sum: {0}",
                    valueFormat: "currency",
                    summaryType: "custom"
                }
            ],
            calculateCustomSummary: function (options) {
                if (options.name === "SelectedRowsSummary") {
                    if (options.summaryProcess === "start") {
                        options.totalValue = 0;
                    }
                    if (options.summaryProcess === "calculate") {
                        if (options.component.isRowSelected(options.value.ID)) {
                            options.totalValue = options.totalValue + options.value.SaleAmount;
                        }
                    }
                }
            }
        }

if(options.summaryProcess ===“ calculate”){部分中,您可以放置​​自定义calc逻辑,在这种情况下,您的总计数。