v7.3.0
SupportExamplesFree Trial

Interacting with the server

Now that we've reviewed the general concepts of working with data in Bryntum components, let's explore server interactions in more detail. There are multiple ways to interact with the server.

For Bryntum Scheduler Pro, you can either use loadUrl to interact with all stores collectively:

project : {
    loadUrl : '/data.php'
}

or use createUrl, readUrl, updateUrl, and deleteUrl to define an endpoint for each store individually. For example:

const schedulerpro = new SchedulerPro({
  // other config
  resourceStore : {
    createUrl : 'resource/create.js',
    readUrl   : 'resource/read.js',
    updateUrl : 'resource/update.js',
    deleteUrl : 'resource/delete.js'
  }
});
// SchedulerProConfig.tsx
import { type BryntumSchedulerProProps } from "@bryntum/schedulerpro-react";

export const schedulerproProps: BryntumSchedulerProProps = {
  // other config
  resourceStore : {
    createUrl : 'resource/create.js',
    readUrl   : 'resource/read.js',
    updateUrl : 'resource/update.js',
    deleteUrl : 'resource/delete.js'
  }
};
import schedulerproProps from "./schedulerproConfig";
// App.tsx
const App = props => {

    return <BryntumSchedulerPro {...schedulerproProps} />
}
<script setup lang="ts">
import { BryntumSchedulerPro } from '@bryntum/schedulerpro-vue-3';
import schedulerproConfig  from './AppConfig.ts';
</script>

<template>
  <bryntum-schedulerpro v-bind="schedulerproConfig" />
</template>
import { type BryntumSchedulerProProps } from '@bryntum/schedulerpro-vue-3';

export const schedulerproConfig : BryntumSchedulerProProps = {
  // other config
  resourceStore : {
    createUrl : 'resource/create.js',
    readUrl   : 'resource/read.js',
    updateUrl : 'resource/update.js',
    deleteUrl : 'resource/delete.js'
  }
};
<bryntum-schedulerpro
    #schedulerpro
    [project]="schedulerproProps.project!"
></bryntum-schedulerpro>
// app.config.ts
import { type BryntumSchedulerProProps } from '@bryntum/schedulerpro-angular';

export const schedulerproProps: BryntumSchedulerProProps = {
  // other config
  resourceStore : {
    createUrl : 'resource/create.js',
    readUrl   : 'resource/read.js',
    updateUrl : 'resource/update.js',
    deleteUrl : 'resource/delete.js'
  }
};
// app.component.ts

export class AppComponent implements AfterViewInit {

    // other config
    schedulerproProps = schedulerproProps;
}
We don't recommend interacting with a store separately. The best is to use the Project for store interactions.

The ResourceStore then uses the URLs for AJAX requests for the different CRUD operations. You'll learn more about the ResourceStore in the store interaction section below.

The project is a top-level entity that holds multiple stores together.

You can pass autoLoad : true, if you want the data to be loaded automatically after a store has been initialized.

const schedulerpro = new SchedulerPro({
  // other config
  resourceStore : {
    autoLoad  : true,
    createUrl : 'resource/create.php',
    readUrl   : 'resource/read.php',
    updateUrl : 'resource/update.php',
    deleteUrl : 'resource/delete.php'
  }
});

Using Fetch

You can use the JavaScript Fetch API to fetch the data and feed it into the Bryntum Scheduler Pro:

const response = await fetch('resource/load.php');
const data = await response.json();

// feed it to SchedulerPro like this:
const schedulerpro = new SchedulerPro({
    resourceStore : {
        data : data
    }
})

// or this:
schedulerpro.resourceStore.data = data;

Understanding Project

The Project provides an easy way to define endpoints for server interactions. It accepts only two endpoints, one for loading data (loadUrl) and another for creating, updating, and deleting data (syncUrl).

const schedulerpro = new SchedulerPro({
  // other config
  project : {
    loadUrl : 'read.js',
    syncUrl : 'sync.js'
  },
})
// SchedulerProConfig.tsx
import { type BryntumSchedulerProProps } from "@bryntum/schedulerpro-react";

export const schedulerproProps: BryntumSchedulerProProps = {
  // other config
  project : {
    loadUrl : 'read.js',
    syncUrl : 'sync.js'
  }

};
import schedulerproProps from "./schedulerproConfig";
// App.tsx
const App = props => {

    return <BryntumSchedulerPro {...schedulerproProps} />
}
<script setup lang="ts">
import { BryntumSchedulerPro } from '@bryntum/schedulerpro-vue-3';
import schedulerproConfig  from './AppConfig.ts';
</script>

<template>
  <bryntum-schedulerpro v-bind="schedulerproConfig" />
</template>
import { type BryntumSchedulerProProps } from '@bryntum/schedulerpro-vue-3';

export const schedulerproConfig : BryntumSchedulerProProps = {
    // other config
    project : {
      loadUrl : 'read.js',
      syncUrl : 'sync.js'
    }
};
<bryntum-schedulerpro
    #schedulerpro
    [project]="schedulerproProps.project!"
></bryntum-schedulerpro>
// app.config.ts
import { type BryntumSchedulerProProps } from '@bryntum/schedulerpro-angular';

export const schedulerproProps: BryntumSchedulerProProps = {
  // other config
  project : {
    loadUrl : 'read.js',
    syncUrl : 'sync.js'
  }
};
// app.component.ts

export class AppComponent implements AfterViewInit {

    // other config
    schedulerproProps = schedulerproProps;
}

Check out the SchedulerPro demo that uses the Project.

The Bryntum component then uses the project to handle CRUD operations for you. Whenever changes are made to tasks, assignments, resources, or anything else, a request is sent to the syncUrl path.

On the backend, you can see the type of change (Create, Update, or Delete) by looking at the request body. Then, based on the operation type, it sends the relevant data.

The following examples use the loadUrl to load the SchedulerPro data with a fake API call using project.

const scheduler = new Scheduler({ appendTo : targetElement, height : 300, rowHeight : 50, columns : [ { text : 'Name', field : 'name', type : 'resourceInfo', width : 160 } ], crudManager : { transport : { load : { url : '/mockUrl' } }, autoLoad : true }, resourceImagePath : 'data/Scheduler/images/users/', startDate : new Date(2025, 1, 1), endDate : new Date(2025, 1, 15) }); // AJAX URL Mocking AjaxHelper.mockUrl('/mockUrl', () => { return { responseText : JSON.stringify(schedulerProData()) }; }); function schedulerProData() { return { resources : { rows : [ { id : 'r1', name : 'Mike' }, { id : 'r2', name : 'Linda' }, { id : 'r3', name : 'Don' }, { id : 'r4', name : 'Karen' }, { id : 'r5', name : 'Doug' }, { id : 'r6', name : 'Adam' }, { id : 'r7', name : 'Lola' } ] }, events : { rows : [ { id : 1, resourceId : 'r1', startDate : new Date(2025, 1, 1, 10), endDate : new Date(2025, 1, 2, 12), name : 'Click me', iconCls : 'b-fa b-fa-mouse-pointer' }, { id : 2, resourceId : 'r2', startDate : new Date(2025, 1, 1, 12), endDate : new Date(2025, 1, 3, 13, 30), name : 'Drag me', iconCls : 'b-fa b-fa-arrows-alt' }, { id : 3, resourceId : 'r3', startDate : new Date(2025, 1, 1, 14), endDate : new Date(2025, 1, 7, 14), name : 'Double click me', eventColor : 'purple', iconCls : 'b-fa b-fa-mouse-pointer' }, { id : 4, resourceId : 'r4', startDate : new Date(2025, 1, 1, 8), endDate : new Date(2025, 1, 5, 11), name : 'Right click me', iconCls : 'b-fa b-fa-mouse-pointer' }, { id : 5, resourceId : 'r5', startDate : new Date(2025, 1, 1, 15), endDate : new Date(2025, 1, 2, 17), name : 'Resize me', iconCls : 'b-fa b-fa-arrows-alt-h' }, { id : 6, resourceId : 'r6', startDate : new Date(2025, 1, 1, 16), endDate : new Date(2025, 1, 3, 19), name : 'Important meeting (read-only)', iconCls : 'b-fa b-fa-exclamation-triangle', eventColor : 'red', readOnly : true }, { id : 7, resourceId : 'r6', startDate : new Date(2025, 1, 4, 6), endDate : new Date(2025, 1, 6, 8), name : 'Sports event', iconCls : 'b-fa b-fa-basketball-ball' }, { id : 8, resourceId : 'r7', startDate : new Date(2025, 1, 7, 9), endDate : new Date(2025, 1, 9, 11, 30), name : 'Dad\'s birthday!', iconCls : 'b-fa b-fa-birthday-cake', // Custom styling from data style : 'background-color : teal; font-size: 18px', // Prevent default styling eventStyle : 'none' } ] } }; }

Store interactions

You can use one of the stores, such as AssignmentStore or ResourceStore, to handle a specific type of store data. For example:

const customAssignmentStore = new AssignmentStore({
  createUrl : "assignment/create.php",
  readUrl   : "assignment/read.php",
  updateUrl : "assignment/update.php",
  deleteUrl : "assignment/delete.php"
});

new SchedulerPro({
  assignmentStore : customAssignmentStore
})

We recommend you use this approach when you have API endpoints for a specific store, like AssignmentStore. The Bryntum Scheduler Pro will then use these endpoints to interact with the server for assignment-related data.

This means you can have multiple data-specific stores:

new SchedulerPro({
  assignmentStore : {
      createUrl : "assignment/create.php",
      readUrl   : "assignment/read.php",
      updateUrl : "assignment/update.php",
      deleteUrl : "assignment/delete.php"
  },
  resourceStore   : {
    createUrl : "resource/create.php",
    readUrl   : "resource/read.php",
    updateUrl : "resource/update.php",
    deleteUrl : "resource/delete.php"
  }
});

This is useful for managing a single store, but management becomes more difficult when you use all your stores this way. Therefore, we encourage you to use the Project to manage your data.

Headers

You can use the headers config to configure requests and send custom HTTP headers to the server:

project : {
  transport : {
    sync : {
        url : 'http://mycool-server.com/sync.php',
        // specify Content-Type for requests
        headers : {
            'Content-Type' : 'application/json'
        }
    }
  }
}

If you want send headers in a separate store :

// Configuring headers for each request
const resourceStore = new ResourceStore({
  readUrl : "resource/read.php",
  headers : {
    "Content-Type"   : "text/xml",
    "Accept-Charset" : "utf-8",
  },
});

Next, let's learn how data is structured for different requests.

Continue reading: Understanding structure.

Contents