Skip to content

Instantly share code, notes, and snippets.

@ashupp
Created April 17, 2021 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashupp/0d28345a49bd5bae3afdcfc913d8407a to your computer and use it in GitHub Desktop.
Save ashupp/0d28345a49bd5bae3afdcfc913d8407a to your computer and use it in GitHub Desktop.
bryntum grid problem exporting excel with nested fields
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