Our blazing fast Grid component built with pure JavaScript


Post by prh7 »

I want to populate data using fetchOptions with headers for populating data into eventStore. I don't see any example of it. I tried doing this below:
import React, { Component } from 'react';
import UnplannedGrid from '../lib/UnplannedGrid';
import Task from '../lib/Task';

class Grid extends Component {

    componentDidMount() {
            this.unplannedGrid = new UnplannedGrid({
                appendTo: 'unplannedContainer',
                eventStore: this.props.eventStore,
                store: {
                    modelClass: Task,
                    updateUrl  : customUpdateUrl,
                    fetchOptions: {
                        method: 'POST',
                        body: JSON.stringify({username: 'example'})
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }
            });
    }

    render() {
        return <div id="unplannedContainer"/>;
    }
}

export default Grid;
It doesn't work.
Additional: how do we normalize data from the response of the request if it works.

Any help will be appreciated.

Post by mats »

Which Scheduler version are you using? fetchOptions was added in 2.0

Post by prh7 »

I am using trial version of scheduler and grid components which says scheduler-2.0.0 Trial. If I am using the correct version, then it should be working with the above code right ?

Post by prh7 »

fetchOptions doesn't work.

Post by mats »

It works fine, just tested it.
let unplannedGrid = new UnplannedGrid({
    id         : 'unplanned',
    appendTo   : 'unplannedContainer',
    eventStore : schedule.eventStore,
    store      : {
        modelClass : Task,
        fetchOptions: {
            method: 'POST',
            body: JSON.stringify({username: 'example'})
        },
        readUrl    : 'data/unplanned.json',
        autoLoad   : true
    }
});
Request headers:
Provisional headers are shown
Content-Type: text/plain;charset=UTF-8
Origin: https://lh
Referer: https://lh/scheduler/examples/dragfromgrid/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
{username: "example"}
username: "example"
Try downloading trial again to get latest sources to be sure?

Post by prh7 »

I don't see any option for me to download again Bryntum trial version?

Post by mats »

Just fill out some email address using the free-trial button? https://bryntum.com/

Post by prh7 »

Thanks that worked @Mats.

One last question: How do I normalize the response received from the above example request? Is there a callback function or property to do it ?

Post by mats »

You can listen for the 'load' event and access the loaded data there?

https://bryntum.com/docs/scheduler/#Com ... event-load

Post by prh7 »

Any example how this load event works would be helpful.

Post Reply