I am trying to get a dgrid OnDemandGrid to work with dijit.form.DateTextBox as an editor. The data is fed to OnDemandGrid via JSON. Initially, I was trying to feed dates in the raw format from the MySQL database (e.g. YYYY-MM-DD HH:MM:SS
), however when DateTextBox seemed incapable of parsing that string, I tried feeding it just the date (e.g. 2012-11-20
). However, this too failed to work.
So, my primary issue is getting DateTextBox to process the date information. A secondary issue is how to deal with the time information, since DateTextBox cannot edit times. My current approach is that when I split the SQL date string, I am feeding dgrid the time as a separate column for a dijit.form.TimeTextBox. This seems like a messy solution, so I'm open to suggestions.
Here's my grid code:
var grid = new declare([OnDemandGrid, Editor, Keyboard, Selection])({
store: store,
query: {aid: "1900", action: "objectListGenerator2" },
bufferRows: 40,
loadingMessage: "Loading...",
columns: [
{field: "oid", label: "Object ID"},
Editor({field: "startDate", name: "Start Date", editorArgs: { selector: 'date', datePattern: 'yyyy-mm-dd', locale: 'en-us' }}, DateTextBox, "click"),
Editor({field: "startTime", name: "Start Time"}, TimeTextBox, "click"),
Editor({field: "endDate", name: "End Date"}, DateTextBox, "click"),
Editor({field: "endTime", name: "End Time"}, TimeTextBox, "click"),
{field: "endDateOid", label: "End OID"}
],
}, "grid");
Here's a sample string of my JSON source:
[{"content":"2012-11-20 18:12:00","oid":"2112","author":"","endDateOid":"2113","group":"","endTime":"17:59:00","poid":"0","id":null,"startTime":"18:12:00","gmt":"2012-11-22 00:12:43","name":"The Windows 8 Disaster Rolls On","paid":"1900","endDate":"2012-11-21","type":"startDate","startDate":"2012-11-20","cache":"","cachedate":"0000-00-00 00:00:00"},
{"content":"2013-01-01 17:59:00","oid":"2114","author":"","endDateOid":"2115","group":"","endTime":"16:59:00","poid":"0","id":1,"startTime":"17:59:00","gmt":"2012-11-22 00:14:49","name":"The Windows 8 Disaster Rolls On","paid":"1900","endDate":"2013-01-02","type":"startDate","startDate":"2013-01-01","cache":"","cachedate":"0000-00-00 00:00:00"}]