Dojo datagrid with date and time

拥有回忆 提交于 2020-01-13 19:23:48

问题


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.


回答1:


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' });
        }

......




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/4874381/dojo-datagrid-with-date-and-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!