Continuously add new record after current new record saved?

5 posts, 1 answers
  1. Wicky
    Wicky avatar
    26 posts
    Member since:
    Jul 2006

    Posted 17 Feb 2013 Link to this post

    Hello,

    I would like to continuously add new record (popup edit) after current new record saved, is it possible?
    Is there "saved" event could be used?

    Thanks
    Wicky
  2. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 19 Feb 2013 Link to this post

    Hello Wicky,

    There is a save event, however it is not suitable for this task. I assume that you work with remote data and submit the changes to the server.

    In such case, you should hook up to the requestEnd event of the dataSource which will fire after the dataSource request finishes successfully. If the operation type was create, you should hook up once to the dataBound event of the Grid and insert new row via addRow method. Basically the code is:
    requestEnd: function (e) {
        var type = e.type,
            grid = $("#grid").data("kendoGrid");
     
        if(type === "create") {
            grid.one("dataBound", function() { this.addRow(); });
        }
    }

    I hope this approach will fit in your scenario.

    Kind regards,
    Alexander Valchev
    the Telerik team
    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
  4. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 02 Oct 2014 in reply to Alexander Valchev Link to this post

    What is descirbed by Alexander worked fine for us - until the last update.

    Was there a change so that this no longer works? 
  5. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 02 Oct 2014 in reply to Volker Link to this post

    Sorry, I did a test now in your online-demo by adding the suggested code to the popup-edit-demo. As expected, the code no longer works..

    We would really urgently need a working solution again!
  6. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 06 Oct 2014 Link to this post

    Hi Volker,

    The problem occurs because now the Window widget has a closing animation. I can suggest the following workarounds:

    1. (Recommended one) Disable the window animation:

    $("#grid").kendoGrid({
        dataSource: dataSource,
        pageable: true,
        height: 550,
        toolbar: ["create"],
        columns: [
            { field:"ProductName", title: "Product Name" },
            { field: "UnitPrice", title:"Unit Price", format: "{0:c}", width: "120px" },
            { field: "UnitsInStock", title:"Units In Stock", width: "120px" },
            { field: "Discontinued", width: "120px" },
            { command: ["edit", "destroy"], title: " ", width: "200px" }],
        editable: {
          mode: "popup",
          window: {
            animation: false
          }
        }
    });


    2. (Not recommended) Call the addRow method after a given timeout:

    requestEnd: function (e) {
      var type = e.type,
          grid = $("#grid").data("kendoGrid");
     
      if(type === "create") {
        grid.one("dataBound", function() {
          var that = this
          setTimeout(function() {
            that.addRow();
          }, 500);
        });
      }
    }


    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready