This is a migrated thread and some comments may be shown as answers.

Editing with cascaded combo - how to avoid initial ajax call

3 Answers 75 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vasile
Top achievements
Rank 1
Vasile asked on 10 Apr 2013, 06:40 PM
Hello,

I encounter a little annoying issue with cascading combos, tried couple of things but failed to obtain desired behavior so far. I hope someone can suggest a way to address the following problem.

When I edit an entity with cascaded combos (so the entity exists all properties have proper values). I BindTo the combos server side on the view creating the page, I would expect that on the client side the combos will appear with the proper text inside.. so the item with the right value will just be selected on each combo as I provided adequate items to each of them. It works properly for the first combo, but next ones that are cascaded will not use the items that I specified with BindTo on the server wrapper, instead they execute the ajax call and bring again actually the same items that I provided with BindTo. In this time I see in the combobox input the value which is a GUID and it looks really "unfinished".

What is the right way to handle this in order to achieve proper presentation of the combos when the page is just displayed  (one thing that cross my mind is to wire up all cascading infrastructure on the client side - but that would defeat the goal of using MVC wrappers to deal with wiring of cascades).

Thank you
Vasile

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 11 Apr 2013, 09:06 AM
Hello Vasile,

 
The ComboBox widget does not support setting BindTo and DataSource options simultaneously. In other words if Ajax binding is used it will ignore the data set with BindTo method.
In general, you can set the autoBind to false and define value and text options of the widget in order to prevent initial request. Please note that if the widget is not bound and its value method is called it will request the server. MVVM will call  widget value method if the model property has value. You can check this code library, which shows how to use cascading widgets as an editor template.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vasile
Top achievements
Rank 1
answered on 12 Apr 2013, 01:50 PM
Thanks,
I think, base on your feedback, I got some acceptable behavior, actually setting the "Text" property addressed my problem. I was assuming that if I specify BindTo and the Value the control will select the right text.

Perhaps you could consider implementing this behavior because it would really help in scenarios similar like mine. E.g. I use the ComboBox in a EditorTemplate so I use the Model as Value, but for Text I don't see a clean mechanism to pass it to EditorTemplate, I have a way of passing datasource for BindTo to the EditorTemplate and I could change that to pass a class which includes the Text and the enumerable data source, but thsi implies an ugly design that for a particular value I have to calculate the right Text somewhere else which will be little bit messy. For now I just iterate in my EditorTemplate trough passed datasource and identify the item with the right Value and get from it the property for Text but would have been nicer if this would had happen inside ASP MVC combobox wrapper.

So....my proposal would be that even in the case of specifying an ajax data source, if the Value is specified and BindTo is specified, DataTextField & DataValueField ar specified, everthing is there for the wrapper to determine the right text to show.

Thank you,
Vasile
0
Georgi Krustev
Telerik team
answered on 12 Apr 2013, 04:55 PM
Hello Vasile,

 
Thank you for the suggestion. We will log it into our system for further consideration. Depending on the users interest, we will decide whether to schedule this functionality for investigation.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Vasile
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Vasile
Top achievements
Rank 1
Share this question
or