Want to select first item after cancelling create

2 posts, 0 answers
  1. Franz
    Franz avatar
    7 posts
    Member since:
    Oct 2013

    Posted 14 Jan 2015 Link to this post

    When creating a new entry in listview and deciding to cancel the creation, the entry is removed from listview, but I have problems to get first item selected after that.
    The cancel event seems to have a timing problem.
    Here is my ListView:
                 .DataSource(ds => ds 
                     .Model(model =>
                         model.Field(f => f.CompanyId).DefaultValue(@Model.First().CompanyId);
                     .Create(create => create.Action("PermissionGroupCreate", "User"))
                     .Update(update => update.Action("PermissionGroupUpdate", "User"))
                     .Read(read => read.Action("PermissionGroups", "User").Data("additionalData") )
                     .Destroy(destroy => destroy.Action("PermissionGroupDelete", "User"))
                     .Events(e =>
                 .Events(ev =>

    and that is my cancel event:

    function onCancel(e) {
          var listView = $('#lstvPermissionGroup').data('kendoListView');
  2. Nikolay Rusev
    Nikolay Rusev avatar
    2287 posts

    Posted 16 Jan 2015 Link to this post

    Hello Franz,

    Your cancel event handler should look like this:

    cancel: function() {
     this.one("dataBound", function() {

    Cancel event is triggered before the actual cancellation as the event can be prevented. Thus you need some timeout or handle next dataBound event.

    Here is a runnable example - http://dojo.telerik.com/@rusev/OkOWu. All you need is to add new record and then click the cancel button, then first item gets selected.

    Nikolay Rusev

    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