Hi,
I have problem binding the data that's coming back from the API to the combo inside iggrid dialog edit mode.
I tried to bind it during editRowStarted but it wipe out my selection if i didn't select anything. Please find my sample attached
Thanks
editRowStarted: function (evt, ui) { var editor = $("#TestTypeGrid").igGridUpdating("editorForKey", "userId"); if (editor) { editor.igCombo("option", "dataSource", me.users); editor.igCombo("dataBind"); } },
Hello,
The approach with the editRowStarted is correct!
The problem there is, that there is no actual value for combo set. And calling dataBind simply displays the first one.
Also setting new dataSource does not require dataBind. You have to set the value of the igCombo.
All you need should modifying a bit editRowStarted to:
editRowStarted: function (evt, ui) { let editor = $("#TestTypeGrid").igGridUpdating("editorForKey", "userId"); if (editor) { let record = ui.owner.element.igGrid("findRecordByKey", ui.rowID); editor.igCombo("option", "dataSource", me.users); editor.igCombo("value", record.userId); }},
Let me know if you have further questions.
Thank you, it's working fine now. I need to check for the record so it won't blew up on add new row.
Is there a way to add a default empty value in the combo if nothing is selected?
if(record) {editor.igCombo("value", record.userId);}
There is rowAdding parameter and what you should do in this case is to not select any value:
editRowStarted: function (evt, ui) { let editor = $("#TestTypeGrid").igGridUpdating("editorForKey", "userId"); if (editor) { let record = ui.owner.element.igGrid("findRecordByKey", ui.rowID); editor.igCombo("option", "dataSource", me.users); if (!ui.rowAdding) { editor.igCombo("value", record.userId); } }},