Add record results in multiple ajax calls

4 posts, 0 answers
  1. Leader
    Leader avatar
    8 posts
    Member since:
    Jun 2013

    Posted 20 Feb 2015 Link to this post

    When I add a new record to the detail grid in a master/detail grid, I see an ajax call for each exisitng record: ie, if there are 4 records already in the detail grid then there will be 5 posts to the new datail method followed by 5 calls to the show details method. This seems to be both unneccessary and a waste of my server resources. I also have to test for an existing detailId before attempting the insert into the database so that I do not get duplicate records in the databse.

    How can I limit it to just the one insert call for the new record followed by just one grid refresh call.

    Here is my js event handler for the grid edit event:
    /**
     * edit event handler of the curent comments grid.
     * Bound at design time by the grid configuration.
     *
     * @param {event} e
     */
    function commentsEdit(e) {
        if (e.model.isNew()) {
            /**
             * get the participant_hotalert_id from parentData and set it into the model
             */
            e.model.set('participant_hotalert_id', parentData.participant_hotalert_id);
            /**
             * get the current status from parentData and set the status of the new comment.
             * N.B.
             * You have to set the popup window element first or you CANNOT set the value in the model.
             * Both have to be set so that the new comment gets the current status when the user does not change it.
             */
            var status = parentData.status;
            e.container.find('select').val(status);
            e.model.set('status', status);
        }
    }
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 24 Feb 2015 Link to this post

    Hello Andrew,

    By design the dataSource should send only the newly inserted records to the server. What you described might happen in cases where you have not specified the Id of the model that you show inside your Grid or if the ID is actually the default value for that base type.

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.model

    In order to say what exactly is the reason for these requests (that should not happen) please isolate and demonstrate your case with a small example or provide a live URL which we can visit and investigate on.

    Kind Regards,
    Petur Subev
    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 AJAX banner
  4. Leader
    Leader avatar
    8 posts
    Member since:
    Jun 2013

    Posted 24 Feb 2015 in reply to Petur Subev Link to this post

    Petur,

    I have specified an ID. I have attached the page source in a zip and you will see it there.

    We use PHP so please use the php configuration, documentation and examples when answering my questions.
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 26 Feb 2015 Link to this post

    Hello Andrew,

    I inspected the provided code and the configuration looks valid. From this point it seems that either all records received from the server doesn't have the specified ID field ("mid_54ec9ba32f155") or the field value is equal to the default value for it's type. That why we would need example response from the server side (you can get it using your browser network tab or fiddler) in order to investigate further current behavior.

    Regards,
    Vladimir Iliev
    Telerik
     
    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 AJAX banner