Editing with cascaded combo - how to avoid initial ajax call

4 posts, 0 answers
  1. Vasile
    Vasile avatar
    33 posts
    Member since:
    Dec 2010

    Posted 10 Apr 2013 Link to this post

    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
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 11 Apr 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Vasile
    Vasile avatar
    33 posts
    Member since:
    Dec 2010

    Posted 12 Apr 2013 Link to this post

    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
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 12 Apr 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready