Created
April 17, 2021 02:06
-
-
Save ashupp/0d28345a49bd5bae3afdcfc913d8407a to your computer and use it in GitHub Desktop.
bryntum grid problem exporting excel with nested fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Grid, DataGenerator } from '../../build/grid.module.js?449264'; | |
import shared from '../_shared/shared.module.js?449264'; | |
const grid = new Grid({ | |
appendTo : 'container', | |
minHeight : '20em', | |
features : { | |
excelExporter : true | |
}, | |
// Headers will ripple on tap in Material theme | |
ripple : { | |
delegate : '.b-grid-header' | |
}, | |
columns : [{ | |
text : 'Name', | |
field : 'name', | |
flex : 2, | |
editor : { | |
type : 'textfield', | |
required : true | |
} | |
}, { | |
text : 'Age', | |
field : 'age', | |
width : 100, | |
type : 'number' | |
}, { | |
text : 'City', | |
field : 'city', | |
flex : 1 | |
}, { | |
text : 'Food', | |
field : 'innerdata.food', | |
flex : 1 | |
}, { | |
text : 'Color (not sortable)', | |
field : 'color', | |
flex : 1, | |
sortable : false, | |
renderer({ cellElement, value, isExport }) { | |
// During export cellElement might be missing | |
if (!isExport) { | |
// renderer that sets text color = text | |
cellElement.style.color = value; | |
} | |
return value; | |
} | |
}], | |
data : DataGenerator.generateData(50), | |
data: [ | |
{name: 'alex ash', city: 'detroit', age: 19, color: 'red', innerdata: {food: 'pizza'}} | |
], | |
tbar : [ | |
{ | |
type : 'button', | |
text : 'Export (default settings)', | |
ref : 'excelExportBtn1', | |
onAction : () => grid.features.excelExporter.export() | |
}, | |
{ | |
type : 'button', | |
text : 'Export (custom columns)', | |
ref : 'excelExportBtn2', | |
onAction : () => grid.features.excelExporter.export({ | |
exporterConfig : { | |
columns : [ | |
{ text : 'First Name', field : 'firstName', width : 90 }, | |
{ text : 'Age', field : 'age', width : 40 }, | |
{ text : 'food', field : 'innerdata.food', width : 40 }, | |
{ text : 'Starts', field : 'start', width : 140 }, | |
{ text : 'Ends', field : 'finish', width : 140 } | |
] | |
} | |
}) | |
} | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment