Dojo datagrid with date and time

8.9k views Asked by At

Could someone here please, for the love of God!, post an example of an working dojox.grid.DataGrid using a dojox.data.JsonRestStore, with 2 columns, date and time?

I have tried the following :

<th field="startdate" cellType="dojox.grid.cells._Widget" widgetClass="dijit.form.DateTextBox" editable="true" formatter="formatDate"></code></pre> and 
<th field="starttime" cellType="dojox.grid.cells._Widget" widgetClass="dijit.form.TimeTextBox" editable="true" formatter="formatDate">

Also :

<th field="startdate" cellType="dojox.grid.cells.DateTextBox" editable="true" formatter="formatDate"></code></pre> and 
<th field="starttime" cellType="dojox.grid.cells._Widget" widgetClass="dijit.form.TimeTextBox" editable="true" formatter="formatDate">

but nothing seems to work. It's been two days now and I've been reading tons of documentation and reports but I couldn't find a working example anywhere.

EDIT :

I am now facing the weirdest issue in my programmer's career : the grid is now working fine with DateTextBox and TimeTextBox (this case works in Firefox 3.6.6 and in 3.6.14pre, Internet Explorer 8 and Google Chrome.), except for the following :

In Firefox 3.6.13, with an even number of items in the grid, when I try editing the time or date of one element the widget box appears in the top left corner, the date isn't selected properly and the browser crashes with the CPU going to 100%.

However, if the number of items is odd the editing of date and time works just fine. I have absolutely no idea of what to do so please bounce some ideas.

3

There are 3 answers

0
Vin.X On BEST ANSWER

you can keep the values in the grid to be date type but with your customized format....the grid will take care of sorting.....no need to write customized sorting for some simple field like Date.... ......

var yourLayout = [[
 { 'name': 'Date', 'field': 'dateCol', 'width': '15%', 'formatter': this.formatDate}
]];

..............

formatDate: function(dateValue) {
                return dojoLocale.format(dateValue, { selector: 'date', formatLength: 'long' });
        }

......

4
Jakob Aarøe Dam On

There is an example of what you are trying to do in the dojo test suite. It's not actually using the JsonRestStore but that doesn't matter.

http://archive.dojotoolkit.org/nightly/checkout/dojox/grid/tests/test_edit_dijit.html

The best dojo documentation around are the tests.

0
peller On

If it helps, Oliver has added some examples of how to format dates in a grid, with and without editable dijit widgets. This still needs to be incorporated into the main documentation.