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.
if you would like to locate a specific combo in a templated row, i suggest ti get the row element by relying on its data-id attribute (or just the index), which the grid renders, then locating the combo as a child of that row element, using some of its CSS classes as a selector.
example:
var row = $("#grid1").igGrid("rowAt", <index>);
var combo = $(row).find(".ui-igcombo");
Or row by primary key:
var row = $("#grid1").find("tr[data-id='<your ID>']");
Hope it helps. Thanks,
Angel
If I try to do:
$(document).find(".ui-igcombo")
I am the unable to take datasource and to query it...
Any ideas?
Flavio M.
Hello 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.
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
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.
That's OK Martin,
Thank you very much for your help!!!