Hi,
Is there a way to add ID attribute to a combo editor inside igGrid ? I'm using MVC helper to set the combo editor but there's no property that does that I don't think.
That's OK Martin,
Thank you very much for your help!!!
Flavio M.
Hello Flavio,
ColumnUpdatingComboEditorOptions class doesn't have a property for setting "ID" of the combo. And there is no other way to set it in this class. The workaround as you suggested is to use a ColumnUpdatingSetting.EditorOptions property which is a string property. You can set the dataSource by serializing the List<Customer> using the System.Web.Script.Serialization.JavaSctiptSerializer class.
Here is an example code:
ColumnUpdatingSetting productSetting = new ColumnUpdatingSetting();
productSetting.ColumnKey = "ProductID";
JavaScriptSerializer serializer = new JavaScriptSerializer();
productSetting.EditorOptions = String.Format("id: 'myCustomId', valueKey: 'ProductID', textKey: 'Name', dataSource: {0}", serializer.Serialize(GetProducts()));
Hope this helps,Martin PavlovInfragistics, Inc.
Ok Martin, I solved ;-)
As you suggested I saw that example and I copy the idea that combo editor is not generated at a very first time.So what I did?
As you can see, my big problem was "how to catch the igCombo dataSource". With the bold sentence it is perfectly done.
However, it would be interesting to know how to set ID directly from controller or to pass datasource directly from controller to the GridModel by editorOptions...
Thanks
Hi Martin,
thank you very much for your answer.
You're right, but in that sample combo ID is assigned by cshtmlView side. In my case I need to set it byController side, and I am not able to find that option...
ColumnUpdatingComboEditorOptions updatingComboEditorOptions = new ColumnUpdatingComboEditorOptions(); updatingComboEditorOptions.DataSource = customers.AsQueryable(); updatingComboEditorOptions.DropDownOnFocus = true; updatingComboEditorOptions.ShowDropDownButton = false; updatingComboEditorOptions.ValueKey = "CustomerId"; updatingComboEditorOptions.TextKey = "CustomerName"; updatingComboEditorOptions.FilteringType = ComboFilteringType.Local; updatingComboEditorOptions.ID = ...
For sure I could try in this way:
ColumnUpdatingSetting uSetCustomer = new ColumnUpdatingSetting();uSetCustomer .EditorOptions = "id: 'combo_fornitori'" + ",dataSource: ???" ",valueKey: 'IdFornitore'" + ",textKey: 'RagioneSocialeFornitore'" + ",dropDownOnFocus : true" + ",showDropDownButton : false" + ",filteringType : 'local'";
But what about datasource? What have I to specify for it? Take in account that I have a List<Customer> list by controller side that I can set AsQueryable... But I really don't know how to set it in my action GridModel creation...
Flavio
You can look into the: Editing Combo Editor sample. There the combo editor has an ID set to it.
Best regards,Martin PavlovInfragistics, Inc.