I have an igCombo that on page load, selects an item as the default. I am trying to set this selected value to another hidden form field called "OrderTypeHidden", that I have created, but do not know how to get the selecteditem.
<div id="combo_OrderTypes"></div>
<input type="text" name="OrderTypeHidden" id="OrderTypeHidden">
<script>
$.get("../order/Json_OrderTypes", function (data) { //Get $("#combo_OrderTypes").igCombo({ dataSource: data, selectedItems: [{ index: 5 }, { text: "S" }], valueKey: "Order_Type", textKey: "Order_Type", width: "100px", dropDownWidth: 500, itemTemplate: "<div class='comboItemContainer'><div class='colOne'>${Order_Type}</div><div class='colTwo_NoDash'>${Description}</div></div>"
});
$("#combo_OrderTypes").igCombo("setFocus");
}, "json");
</script>
I get no such method 'itemByValue' for igCombo widget instance when trying to call itemByValue.
I get a similar message when trying to get selectedIndex.
Am I missing something? I'm using 2016.1
I came across this and I wanted to add the MVC equivalent for anyone who was looking do do this specifically in MVC, it is very similar but a little different:
@(Html.Infragistics().Combo()
.ID("combo_OrderTypes").DataSource(ViewBag.Data) <-set this this thew controller>.ValueKey("Order_Type").TextKey("Order_Type").SelectedIndexes( new int[]{5}) <- this is usually going to be a Model value ie (new int[]{Model.PropertyId}).ItemTemplate( "<div class='comboItemContainer'><div class='colOne'>${Order_Type}</div><div class='colTwo_NoDash'>${Description}</div></div>").Width(100).Render()
)
Hello James,
Please feel free to contact me if you need any further assistance with this matter.
Thank you for posting in our community.
What I can suggest for getting the selected item is using selectedIndex method of the igCombo API. With this method the index of currently selected item could be retrieved. Afterwards, the item itself could be accessed using itemByIndex method. This could be achieve as following:
[code]
<script> $(function () {
var data = [ { "ID": 1, "Name": "John Smith", "Age": 45 }, { "ID": 2, "Name": "Mary Johnson", "Age": 32 }, { "ID": 3, "Name": "Bob Ferguson", "Age": 27 } ];
$("#combo").igCombo({ dataSource: data, //JSON Array defined above selectedItems: [{ index: 1 }], valueKey: "ID", textKey: "Name" }); //get selected item index var index = $("#combo").igCombo("selectedIndex"); //get the item with the corresponding index var item = $("#combo").igCombo("itemByIndex", index); //get item`s text var text = item.text; //set hidden input value $("#Hidden1").val(text); alert($("#Hidden1").val()); //debugger; }); </script>
[/code]
I made a msall project and I am attaching it for your reference.
In my sample initially, there is a selected item from the combo. Afterwards I am getting item`s index and the item itself. Hidden`s field value is set and afterwards an alert with the values appears.
I believe you might consider the following link to the igCombo`s API useful:
help.infragistics.com/.../ui.igcombo
I hope you find this information helpful.
Please let me know if you need any further assistance with this matter.