The ComboInitialSelectedItemsSettings object seems to only accept a single Value or single Index.I have MultiSelection enabled on my combo so I would like to set multiple inital values. How do I do this using the MVC helpers?
Hello,
Thank you for reaching out with your query regarding setting multiple initial selected items in the Infragistics MVC Combo box with multi-selection enabled.
To achieve this using the MVC helpers provided by Infragistics, you can utilize the InitialSelectedItems method. This method accepts an array of objects where each object specifies either an index or a value property to indicate which items should be initially selected.
Here’s an example of how you can implement this in your MVC view:
@(Html.Infragistics().ComboFor(item => item.EmployeeID)
.Width("270px")
.DataSource(Url.Action("data-source"))
.ValueKey("ID")
.TextKey("Name")
.MultiSelectionSettings(ms =>
{
ms.Enabled(true); // Ensure multi-selection is enabled
})
.InitialSelectedItems(new[]
new { index = 0 }, // Replace with actual indices or values you want to select
new { index = 1 },
new { index = 2 }
.DataBind()
.Render()
)
In this example:
Please adjust the ValueKey and TextKey parameters to match the properties of the objects in your data source.
If you require any further assistance on the matter, please let me know.
Regards,
Georgi Anastasov
Entry Level Software Developer
Infragistics
Hello Georgi,I cannot find the InitialSelectedItems method in the MVC API. You probably mean ComboInitialSelectedItems?https://www.igniteui.com/help/infragistics.web.mvc~infragistics.web.mvc.combowrapper~comboinitialselecteditemsAccording to your documentation this does not accept an array of objects