Retaining order of elements after POST

14 posts, 0 answers
  1. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 18 Nov 2013 Link to this post

    Hi I have a list of items in a multiselect and I want them to be received in the order that the user has specified when being sent to the controller

    Right now they seem to be sorted by whatever the datasource is sorted by.

    Any tips?
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 20 Nov 2013 Link to this post

    Hi Matt,

    I would recommend you to check this example which demonstrates similar behavior.

    Regards,
    Alexander Popov
    Telerik
    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. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 20 Nov 2013 Link to this post

    There is no server involved in that example

    How can I insert those ordered elements back into the MultiSelect's input element to retain order on POST?

    Surely an widget which displays an ordered list should behave like one
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 21 Nov 2013 Link to this post

    Hi Matt,

    I am not sure I understand you correctly. In this screencast you can see that the data is sent in the order it was selected by using the dataItems method and a simple Ajax request.
    Let me know if I am missing something.

    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 21 Nov 2013 Link to this post

    I don't think you understand, I would make a demo project but you don't support VS2013 yet and I'm not installing 2012 just to start one...

    See attached image, below is the client code
    @(Html.Kendo().MultiSelectFor(model => model.Values)
                .AutoBind(true)
                .DataSource(dataSource =>
                {
                    dataSource.Read(Model.DataSource, "Field");
                })
                .DataTextField("Text")
                .DataValueField("Value"))
  7. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 25 Nov 2013 Link to this post

    Hello again Matt,

    Indeed, I misunderstood your question and I apologize for that.
    I reviewed the attached screenshot and now fully understand the issue. The screenshot however, does not reveal any of the implementation and there is not enough information to determine what is causing this. Could you please provide a runnable project where the issue is reproduced or at least the source code of the involved views and controllers? This would help us pinpoint the exact reason for this behavior.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 25 Nov 2013 Link to this post

    Why is this forum so buggy I can't upload anything and half my posts don't go through

    edit: apparently it did upload but gave me an error anyway
  9. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 27 Nov 2013 Link to this post

    Hello Matt,

    Thank you for the attached project. I examined it and noticed that the data is passed to the Controller through a form. Please note that when using such approach the browser is not sending the MultiSelect's values, but rather the value of select HTML element used for initializing it. You can see an example in the attached screenshot.
    In the current scenario I would recommend passing the data using Ajax request - this will allow you to get the values of the MutiSelect's instance in the exact same order it was picked by the user.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  10. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 27 Nov 2013 Link to this post

    So is Kendo dropping support for forms?

    It would have been nice to have it written somewhere that Kendo isn't going to be WCAG compliant
  11. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 28 Nov 2013 Link to this post

    Hello Matt,

    This is a limitation coming from the fact, that when a form is submitted the browser sends the values of the HTML elements inside that form. KendoUI does not affect this behavior and therefore cannot fully support forms in the terms you expect it to.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  12. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2012

    Posted 28 Nov 2013 Link to this post

    It's a bug.

    Make the widget reorder the DOM multi select entries.
  13. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 02 Dec 2013 Link to this post

    Hello,

    This is the the expected, standard behavior of the widget and I am afraid that the behavior you expect is currently not supported out of the box.
    I would however, encourage you to submit this idea at KendoUI UserVoice, so we and other members of the community can evaluate, comment on and vote for it. Most voted ideas are included in next KendoUI releases.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  14. Shehab
    Shehab avatar
    8 posts
    Member since:
    Mar 2014

    Posted 16 Dec 2014 Link to this post

    I agree with Matt, this is not an acceptable behavior from the MultiSelect, and it should be supported.
  15. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 18 Dec 2014 Link to this post

    Hello Shehab,

    Thank you for your feedback. I already explained why this is not supported and suggested to submit a feature request on our feedback portal. For convenience I also prepared an example showing how to manually reorder the items in the way they were selected in the widget.

    Regards,
    Alexander Popov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready