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!
Hello anbalher,
In this scenario the combo is only going to display the value coming from the model as long as it is matched with a corresponding value in the set datasource. The DataSource property used in this case is looking for a local object as the combo's datasource, and as the call is failing the model data is not displayed.
Therefore I suggest using the DataSourceUrl option to ensure that the combo is bound correctly.
A related example may be seen at:
http://help.infragistics.com/Help/Doc/jQuery/2012.1/CLR4.0/html/Configuring%20ASP.NET%20MVC%20Validation.html
Hope this helps. Please do not hesitate to contact me with 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?
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())
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.