Posted 15 August 2019, 8:35 pm EST
Hi,
I am using import excel functionality to import the data from excel sheet to wijmo flex grid. The current behavior works fine when I import the data using header property but when I try to save this data into my model (which use binding property), it wouldn’t happen. Please let me know how to achieve import functionality using “binding” property ? Also please suggest how to set width dynamically to * after imports so that it covers full grid.
Below is the code I am using to try to implement this feature:
bindImportedDataIntoModel() {
const newData = _.cloneDeep(this.getImportedCVData());
let columns = JSON.parse(this.flex.columnLayout).columns;
this.data = new wjcCore.CollectionView(newData);
this.flex.autoGenerateColumns = true;
this.flex.itemsSource = this.data;
this.flex.collectionView.refresh();
const newCol = JSON.parse(this.flex.columnLayout).columns;
newCol.splice(0, columns.length);
columns = { columns: newCol };
this.flex.columnLayout = JSON.stringify(columns);
this.model[0] = _.cloneDeep(newData);
}
getImportedCVData() {
const arr = [];
let nullRow = true;
for (let row = 0; row < this.flex.rows.length; row++) {
nullRow = true;
const item = {};
for (let column = 0; column < this.flex.columns.length; column++) {
const cellValue = this.flex.getCellData(row, column, false);
if (cellValue) {
nullRow = false;
if (this.flex.columns[column].header) {
item[this.flex.columns[column].header] = cellValue;
}
} else {
if ((column === this.flex.columns.length - 1) && nullRow) {
break;
}
}
}
if (nullRow) {
break;
}
arr.push(item);
}
return arr;
}