我有一个dxDataGrid,有4个级别的分组。我也有总结' “分组项目”的配置' SUM各种字段并为每个组创建某种摘要数据。但是,默认情况下,devExpress会在所有组级别(我不想要的)中冒泡这个SUM,而是我想使用'摘要'行为只针对我的第4组和第3组,然后有自定义逻辑(函数或其他),我可以计算第2组的汇总值。
我目前有第4组和第3组汇总数据显示在网格上没有问题。但是,我无法看到我可以启用的任何自定义选项,以便为特定列组(在我的情况下,练习)中提供自定义摘要。
我目前正在使用DevExpress Extreme(JS)v16.1.6。但是,如果这在Kendo UI等其他技术中可行,那么知道如何在那里做这件事会很好,因为我计划在不久的将来从DevExpress迁移到Kendo UI。
我附上了截图,以便你们可以更好地想象我的问题。 Example
这是我的DataGrid的JS代码。
dxDataGrid: {
dataSource: myDataSource, //AJAX Call
grouping: {
autoExpandAll: false
},
rowAlternationEnabled: true,
allowColumnResizing: true,
columnAutoWidth: true,
sorting: { mode: 'multiple' },
searchPanel: { visible: true, width: 240, placeholder: 'Search...' },
filterRow: { visible: true },
loadPanel: { enabled: true },
export: { enabled: true, fileName: 'My Test Report' },
paging: { enabled: true },
grouping: {
autoExpandAll: false
},
groupPanel: {
visible: true,
allowColumnDragging: false
},
pager: {
showPageSizeSelector: true,
showNavigationButtons: true,
showInfo: true
},
onCellPrepared: function(e) {
if (e.rowType === 'group' && e.row.groupIndex <= 1 && e.columnIndex > e.row.groupIndex + 1) {
// e.cellElement.text(''); //This is bad, need to Find a solution now
}
else if (e.column.dataField === 'TotalPacCostPercentage') {
var pacPercentage = parseFloat(e.value) * 100;
if (pacPercentage >= 25 && pacPercentage <= 75) {
e.cellElement.addClass('medium-risk');
}
else if (pacPercentage > 75) {
e.cellElement.addClass('high-risk');
}
}
},
columns: [
{ dataField: 'CountyName', caption: 'County', groupIndex: 0},
{ dataField: 'PracticeNameAndTin', caption: 'Practice', groupIndex: 1 },
{ dataField: 'ProviderDisplayName', caption: 'Provider', groupIndex: 2 },
{ dataField: 'CcsGroupName', caption: 'CCS Group', groupIndex: 3 },
{ dataField: 'CcsName', caption: 'CCS Name', allowGrouping: false },
{ dataField: 'ClaimTypeName', caption: 'Claim Type', allowGrouping: false },
{ dataField: 'PlaceOfServiceName', caption: 'Place of Service', allowGrouping: false },
{ dataField: 'PreTriggerCost', caption: 'Average Pre-Trigger', format: 'currency', allowGrouping: false },
{ dataField: 'PreTriggerPacCostPercentage', caption: 'Pre-Trigger PAC %', format: 'percent', allowGrouping: false },
{ dataField: 'TriggerCost', caption: 'Average Trigger', format: 'currency', allowGrouping: false },
{ dataField: 'TriggerPacCostPercentage', caption: 'Trigger PAC %', format: 'percent', allowGrouping: false },
{ dataField: 'PostTriggerCost', caption: 'Average Post-Trigger', format: 'currency', allowGrouping: false },
{ dataField: 'PostTriggerPacCostPercentage', caption: 'Post-Trigger PAC %', format: 'percent', allowGrouping: false },
{ dataField: 'TotalCost', caption: 'Average Cost', format: 'currency', allowGrouping: false },
{ dataField: 'TotalPacCostPercentage', caption: 'PAC %', format: 'percent', allowGrouping: false }
],
summary: {
groupItems: [
{ column: 'PreTriggerCost', summaryType: 'sum', valueFormat: 'currency', displayFormat: '{0}', alignByColumn: true },
{ column: 'TriggerCost', summaryType: 'sum', valueFormat: 'currency', displayFormat: '{0}', alignByColumn: true },
{ column: 'PostTriggerCost', summaryType: 'sum', valueFormat: 'currency', displayFormat: '{0}', alignByColumn: true },
{ column: 'TotalCost', summaryType: 'sum', valueFormat: 'currency', displayFormat: '{0}', alignByColumn: true },
]
}
}
答案 0 :(得分:0)
您有以下summary types
对于自定义,您可以create a custom function,如下所示:
$("#gridContainer").dxDataGrid({
// ...
summary: {
totalItems: [
{ summaryType: 'custom', name: 'CustomSummary1' },
{ summaryType: 'custom', name: 'CustomSummary2' }
],
calculateCustomSummary: function (options) {
// Calculating "CustomSummary1"
if (options.name == 'CustomSummary1') {
if (options.summaryProcess == 'start') {
// Initializing "totalValue" here
}
if (options.summaryProcess == 'calculate') {
// Modifying "totalValue" here
}
if (options.summaryProcess == 'finalize') {
// Assigning the final value to "totalValue" here
}
}
// Calculating "CustomSummary2"
if (options.name == 'CustomSummary2') {
// ...
// Same "if" statements here
}
}
}
});