This is a migrated thread and some comments may be shown as answers.

Add record results in multiple ajax calls

3 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leader
Top achievements
Rank 1
Leader asked on 20 Feb 2015, 02:45 PM
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);
    }
}

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Feb 2015, 11:52 AM
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!
 
0
Leader
Top achievements
Rank 1
answered on 24 Feb 2015, 04:47 PM
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.
0
Vladimir Iliev
Telerik team
answered on 26 Feb 2015, 12:54 PM
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!
 
Tags
Grid
Asked by
Leader
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Leader
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or