Create event causes three requests to the server.

Ask for help related to our Calendar 2.x version
Post Reply
User avatar
retokiefer
Posts: 5
Joined: Mon Aug 03, 2020 8:36 pm

Create event causes three requests to the server.

Post by retokiefer »

Dear all,

whenever the create event dialog ist saved, there are three (3) requests to the server. And I wonder how to send the request only once because three events are created on the server.

I've red in the forum, that the JSON response from the server must habe a certain format. This is what I sent back from the server after the successful creation of an event:

Code: Select all

{"Id": 125, "Name": "Test", "ResourceId": null, "StartDate": "2019-09-06T17:00:00+02:00", "EndDate": "2019-09-06T18:00:00+02:00", "AllDay": false, "RecurrenceRule": null, "Success": true}

Any help is highly appreciated and thanks in advance,

Reto


User avatar
mats
Core Developer
Core Developer
Posts: 17066
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Create event causes three requests to the server.

Post by mats »

Sounds strange, it should issue just one request. Response should look like:

(data is your root property)

Code: Select all

{
  "success": "true",
  "data": [
    {
      "id": 1,
      "name": "Philip J. Fry"
    },
    {
      "id": 2,
      "name": "Hubert Farnsworth"
    },
    {
      "id": 3,
      "name": "Turanga Leela"
    },
    {
      "id": 4,
      "name": "Amy Wong"
    }
  ]
}
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
retokiefer
Posts: 5
Joined: Mon Aug 03, 2020 8:36 pm

Re: Create event causes three requests to the server.

Post by retokiefer »

Thanks Mats, but this didn't made a difference.

AutoSync is enabled, maybe that's the problem. Basically I am using your example of the MVVM Calendar with the following modifications:

Code: Select all

stores : {
        calendars : {
            type    : 'calendarresourcestore',
            storeId : 'resource',
            data    : [
                { "Id" : 1, "Name" : "Work", "Color" : "#249fbc" },
                { "Id" : 2, "Name" : "Birthdays", "Color" : "#ffc107" },
                { "Id" : 3, "Name" : "Hobbies/Courses", "Color" : "#e44959" }
            ]
        },
        events    : {
            type    : 'calendareventstore',
            storeId : 'event',
            autoSync: true,
            proxy: {
                type: 'ajax',
                api: {
                    read: 'localhost/api/listTeilnahmen',
                    create: 'localhost/api/listTeilnahmen',
                    update: 'localhost/api/listTeilnahmen',
                    destroy: 'localhost/api/listTeilnahmen',
                },
                reader: {
                    type: 'json',
                    rootProperty: 'records',
                    totalProperty: 'totalrecords',
                    idProperty: 'id',
                },
                writer: {
                    type: 'json',
                    writeAllFields: true,
                    expandData: true,
                }
            },
      }
}

Thanks in advance and best regards,

Reto


User avatar
retokiefer
Posts: 5
Joined: Mon Aug 03, 2020 8:36 pm

Re: Create event causes three requests to the server.

Post by retokiefer »

The api URLs are different ones of course. The rest of your example is the same.


User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 3390
Joined: Fri Apr 01, 2016 11:08 am

Re: Create event causes three requests to the server.

Post by pmiklashevich »

Pavel Miklashevich - Core Developer

Post Reply