Hi,
How to bind Dropdown to diffrenet datasources based on condition in Hierarichal grid edit mode.
Thanks,
Kumar
Hello Kumar,
Thank you for posting in our forum.
You can use the editCellStarted event, which will fire when editing has started for a cell, get reference to the combo editor (ui.editor) and change its dataSource based on your condition .
For example:
editCellStarted: function(evt, ui){
if( ui.columnKey === "Name"){
var newData;
if(ui.rowID === 0){
newData =[
{ "ID": 0, "Name": "Food1" },
{ "ID": 1, "Name": "Beverages1" },
{ "ID": 2, "Name": "Electronics1" }
];
}else {
newData = northWindCategoriesJSON;
}
var dropDown= ui.editor;
//set New DataSource
$(dropDown).igCombo("option", "dataSource",newData);
The above code will apply a different data source based on the edited row’s index for a column with key “Name”.
I’ve attached a sample for your reference where this is applied for both the root and child levels.
Let me know if you have any questions or concerns.
Best Regards,
Maya Kirova
Infragistics, Inc.
http://es.infragistics.com/support
Thanks for the quick response. I am looking to bind dropdown from database table.
Hello Ravi,
You can setup a remote endpoint (could be an MVC Action, a service or something else) that will return the data from your database in a JSON format and you can retrieve that JSON data from the client using an ajax request to that endpoint.
The retrieving of the combo editor and the way its data is changed will be the same as in the previously attached sample.
Let me know if you have any questions.