Our powerful JS Calendar component


Post by tornikezhizh »

Hello, I have weird scenario there, when I update endTime or StartTime, sync request acts very weird, sometimes it passes both start and end date/time, sometimes only one of them and + automatically calculated duration, but duration unit never passed to request, and as far as I understand, sometimes it comes in hours, like when difference between start time and end time is 30 minutes, duration is 0.5, but if difference is 38 minutes, duration is 0.02638888888888889M, which is not in hours, but in days and I can't apply correct logic, since I don't receive duration unit. What will be best solution in case like this?


Post by johan.isaksson »

Hello,

On sync, only the changes are sent by default. Duration will be in the unit it was loaded in, if the unit had changed too it would be part of the sync. So the duration you received is in the unit that was sent in the load, or in the default duration unit if it is a new event record.

If you prefer, you can configure it to send all fields in the sync. See https://bryntum.com/products/calendar/docs/api/Scheduler/data/CrudManager#config-writeAllFields

Best regards,
Johan Isaksson

Post by tornikezhizh »

thanks, I found alwaysWrite and changes js script like this, but still I don't get all those fields in request

 startDateField: {
            weight: 180,
            label: 'Start',
            type: 'dateField',
            name: 'startDate',
            format: 'DD/MM/YYYY',
            alwaysWrite : true,
            listeners: {
                change: editorHelper.onStartDateChange
            }
        },

    startTimeField: {
        weight: 190,
        type: 'timeField',
        name: 'startDate',
        alwaysWrite: true,
        step: '30min',
        picker: {
            items: {
                minute: {
                    step: 15
                }
            }
        },
    },

    endDateField: {
        type: 'dateField',
        weight: 193,
        name: 'endDate',
        format: 'DD/MM/YYYY',
        readOnly: true,
        alwaysWrite: true,
    },

    endTimeField: {
        weight: 195,
        type: 'timeField',
        name: 'endDate',
        step: '30min',
        alwaysWrite: true,
        picker: {
            items: {
                minute: {
                    step: 15
                }
            }
        },
    },

Post by alex.l »

https://bryntum.com/products/calendar/docs/api/Core/data/field/DataField#config-alwaysWrite is a config for data field and not for form field. You need to define this in your Model or Store configuration, depends on the code you use.
https://bryntum.com/products/calendar/docs/api/Core/data/AjaxStore#config-fields
https://bryntum.com/products/calendar/docs/api/Core/data/Model

class Person extends Model {
    static get fields() {
        return [
            'name',
            { name : 'birthday', type : 'date', format : 'YYYY-MM-DD', alwaysWrite : true },
            { name : 'shoeSize', type : 'number', defaultValue : 11 },
            { name : 'age', readOnly : true }
        ];
    }
}

All the best,
Alex


Post by tornikezhizh »

I got it, thank you


Post Reply