Our blazing fast Grid component built with pure JavaScript
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.
Which Scheduler version are you using? fetchOptions was added in 2.0
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 ?
fetchOptions doesn't work.
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?
I don't see any option for me to download again Bryntum trial version?
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 ?
Any example how this load event works would be helpful.