Posted 26 December 2017, 6:35 pm EST
Hi Manish,
Thanks for the quick response. Your approach worked.
I need to achieve following use case- On change of combobox value, I need to disable the comboxbox until server response is received.
But as I need to use formatItem.addHandler to dynamically add combobox. And using this approach, grid cells are created every time if any event is fired and so combobox is also created very time. So it is getting complex to achieve the above stated use case.
Isn’t there any other way to dynamically add combobox in columns ? Like DataMap is added to flex.datamap property directly ?
Also on making row isReadyOnly, the combobox in that row doesn’t get into isReadonly state.
Let me know what’s the best way to achieve this use case.
Used following code to create combobox.
grid.formatItem.addHandler((s, e:wjGrid.FormatItemEventArgs)=> {
var editRange = grid.editRange,
column = e.panel.columns[e.col];
// check whether this is an editing cell of the wanted column
if (!(e.panel.cellType === wjGrid.CellType.Cell &&
column === editColumn && e.row!==0)) {
return;
}
// hide standard editor (don't remove!)
if (e.cell.firstChild) {
// e.cell.firstChild.style.display = 'none';
}
e.cell.innerHTML = "";
// add custom editor
var editorRoot = document.createElement('div');
var input;
if (column.dataType === wjCore.DataType.String) {
input = new wjInput.ComboBox(editorRoot);
input.itemsSource = this.countries;
input.displayMemberPath = "country";
input.selectedValuePath = "id";
input.headerPath = "value";
input.isRequired = false;
input.selectedValue = sheet.getCellData(e.row, e.col, false);
// console.log(e.row,e.col,sheet.getCellData(e.row, e.col, false),input.selectedValue)
e.cell.appendChild(editorRoot);
input.focus();
var selection;
input.gotFocus.addHandler((s,e)=>{
selection=sheet.selection;
});
input.lostFocus.addHandler((s,e)=>{
if(selection.row!=0){
sheet.setCellData(selection.row,selection.col,input.selectedValue);
}
});
}
});