Hello, I'm configuring a combo using the MVC helper:
@(Html.Infragistics().ComboFor(m => m.LocalAgent) .ID("comboTest") .TextKey("Info") .ValueKey("Description") .FilterExprUrlKey("value") .FilteringType(ComboFilteringType.Remote) .DataSource("http://localhost/API/GetAgents") .Render())
When the view it's rendered the combo doesn't show the value from model. Why isn't it shown? I also have seen that the combo does this ajax request to the server which doesn't have either:
http://localhost/API/GetAgents?textKey=Info&valueKey=Description&toLower=1&compact=1&_=1385716844622
Why is this request made without value?
Another question is: is there a way to pass the params to the request different to oData?.
Thanks!
Hi Petar, I have suggested a solution for this issue, I would like to know if you would recommend it, do you think it is a good approach? Is there something wrong with it? It works for me but I want to be sure it is ok. Thanks
Hi anbalher, I had the same problem and found a solution. You just have to set DataSource with the item you want to show.
In the controller (using C#):
ViewBag.MyList = new List<MyItem>() { new MyItem() {Key = 10827}, Text = "This is the default value"} };
In the view (using Razor):
@(Html.Infragistics().ComboFor(MyModel => MyModel.MyItemKey) .LoadOnDemandSettings(p => p.Enabled(true).PageSize(15)) .DataSource((List<MyItem>)ViewBag.MyList) .DataSourceUrl(@Url.Action("GetList")) .ValueKey("Key") .TextKey("Text") .HeaderTemplate("<div class='dropDownHeaderFooter'>" + "My header" + "</div>") .FooterTemplate("<div class='dropDownHeaderFooter'>" + "My footer" + " {0} / {3}</div>") .FilteringType(ComboFilteringType.Remote) .DataBind() .Render())
Hello anbalher,
Please feel free to contact me if you have any additional questions regarding this matter.
Apologies for the delayed response.
When load on demand is enabled in the igCombo, only the currently fetched items are available for selection, therefore only a currently fetched item may be selected. A possible approach in this scenario would be to calculate the index of the desired selected item in the whole datasource (if available) and use it to set thepageSizein the loadOnDemand settings. That would ensure that the desired item for selection is fetched initially.
Afterwards the pageSize may be programmatically changed in order to fetch the desired number of records on subsequent user actions.
Hope this helps. Please feel free to contact me if you have any questions.
Thanks for your answer but I've tried with the example from http://www.igniteui.com/combo/load-on-demand.
If I set a default value that is within the first 25 products, the text is displayed : http://jsfiddle.net/F8G78/1/
If I set a default value that isn't within the first 25 products (with selectedItems: [{value: 10827}]) , the text isn't displayed: http://jsfiddle.net/F8G78/2/
¿What should I do to get the text displayed always?