Hi,
I'm using igCombo in an MVC Razor view, configured with remote filtering and load on demand:
@(@Html.Infragistics() .ComboFor(model => model.CompanyID) .DataSourceUrl(Url.Action("GetCompanies")) .TextKey("Name") .ValueKey("ID") .FilteringType(ComboFilteringType.Remote) .FilterExprUrlKey("filter") .LoadOnDemandSettings(load => load.Enabled(true).PageSize(10)) .ResponseDataKey("Records") .DelayFilteringOnKeyUp(500) .ResponseTotalRecCountKey("TotalRecordsCount").ID("companyCombo").Render())
This works mostly, but I have a problem: when the initial value of the Company combo is not in the first 10 companies returned by the remote request, the initial value of the combo is not set, it remains empty.
I checked in the page source that the MVC wrappers correctly sets the initialSelectedElements list to the correct ID in the model.
In the reference: http://help.infragistics.com/jQuery/2015.2/ui.igcombo#options:initialSelectedItems
I read that: "Note: Only items loaded on initialization can be selected. When load-on-demand attempt to select not loaded item will fail."
Ok, fair enough, only the loaded elements can be selected, so that's why it works for the first 10 companied, and not for the rest.
My question is, how can I load this specific element to be selected? So I'd like to load the first 10 elements AND the one that should be initially selected. Would this approach work? If not, how can I set the inital element without loading up all Company entities (there are thousands of them, this is why I use remote filtering and load on demand in the first place)
regards,
Peter
Hello Peter,
Thank you for contacting us.
I am glad that you noticed how our initialSelectedItems works with load on demand feature. Unfortunately it is not possible to load a specific item in order to be selected. Because this kind of data manipulation could not be handled by the combo, my suggestion is to perform some kind of data filter earlier and not to retrieve these thousands of items.
You can use any of the provided methods like value, index or select in order to select items from the combo, once you filter the data.
Filter method:
http://www.igniteui.com/help/api/2015.2/ui.igcombo#methods:filter
Thanks, I managed to fix this by changing the remote datasource, so it would concatenate the item which should be initially selected to the beginning of the returned result set.
About the missing scrollbar, do you have and idea or suggestion?
Ok, I fixed the scrollbar by increasing the page size. This way the list of the options becomes higher, which triggers the scrollbar to show, and by moving it, the incremental loading also works.
I am so happy to hear that!
Thank you for using our controls.