I have a dgrid that has editable date fields. Above it, I have a "Save" button that calls grid.save
. When I hit the button, it makes an XHR request back to the store's target, but does not provide any data back to the server for me to save (i.e. POST is empty). Right now it is hardwired to query item id 1900, as you can see in the code below.
Here is how the store is initiated:
var store = new JsonRest({
target: "/safari/resources/1900/calendarObjects/",
sortParam: "sort",
idProperty: "id",
properties: {
startDate:{
format: "date-time"
},
endDate:{
format: "date-time"
}
}
});
And here is the grid:
var grid = new declare([OnDemandGrid, dgridEditor, Keyboard, Selection, DijitRegistry])({
store: store,
query: {responseType: "json" },
bufferRows: 40,
loadingMessage: "Loading...",
columns: [
{field: "oid", label: "Object ID"},
dgridEditor({field: "startDate", name: "Start Date", editorArgs: { selector: 'date', datePattern: 'yyyy-MM-dd', locale: 'en-us' }}, DateTextBox),
dgridEditor({field: "startTime", name: "Start Time"}, TimeTextBox, "click"),
dgridEditor({field: "endDate", name: "End Date"}, DateTextBox, "click"),
dgridEditor({field: "endTime", name: "End Time"}, TimeTextBox, "click"),
{field: "endDateOid", label: "End OID"}
],
}, "grid");
The save button looks like this:
registry.byId("saveButton").on("click", function (){
grid.save();
});
Like I said, after I click "save," a new XHR request fires, but if it is sending any data back to the server, I'm not sure where it is going. I had my backend print up all of the HTTP headers it received and didn't see anything.
UPDATE (January 2, 2013): Upgraded server backend to use a traditional RESTful URL, which seems to make Dojo slightly happier, but it still is using GET
instead of PUT
and fails to actually send anything to save.
UPDATE (January 5, 2013): Is there any reason why JsonRest would call GET before calling PUT? I'm wondering if my program needs to return certain data before the program is willing to go do the PUT (and thus the problem isn't the GET but whatever comes next)... But, this is entirely speculation. I've reached a dead end.
I'm not sure whether this will work, you can have a look at https://github.com/SitePen/dgrid/blob/master/test/JsonRest.html
and you can try to set the property
getBeforePut
tofalse
.