adding new record with ordering descending edits existing record

2 posts, 1 answers
  1. Greg
    Greg avatar
    3 posts
    Member since:
    Sep 2014

    Posted 03 Jun 2015 Link to this post

    I've got a listview that is backed with a remote datasource.

    I want the datasource to be ordered by the client so that new items added are automatically placed in the correct place (total number of items will not be that many).

    If I order the items using in 'asc', then triggering listview.add() works as expected, however if I reverse the direction so it's 'desc', then listview.add() results in it editing the last item in the list instead.

     

    Example posted here http://dojo.telerik.com/iMArI

    $("#listView").kendoListView({
         dataSource: {
            data: [
                { name: "A Doe" },
                { name: "B Doe" },
                { name: "C Doe" },
            { name: "D Doe" },
                { name: "E Doe" }         
            ],
            sort: [{ field: 'name', dir: 'desc' }]
        },
        template: "<div>#:name#</div>",
        editTemplate: '<div><input type="text" name="name" data-bind="value:name" /></div>'
    });
    // get a reference to the list view widget
    var listView = $("#listView").data("kendoListView");
    // add item
    listView.add();

     

    Kind regards,
    Greg

  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 05 Jun 2015 Link to this post

    Hi Greg,

    This happens because the add method actually puts the first item in edit mode. This behavior is incorrect when using sorting as in the example you shared, so I have logged it as an issue in our public tracker. Until we fix this you can use the workaround demonstrated here.

    As a token of gratitude for your involvement your Telerik points have been updated.

    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. Kendo UI is VS 2017 Ready
Back to Top