看在上帝的份上,这里有人可以发布一个使用 dojox.data.JsonRestStore 的工作 dojox.grid.DataGrid 的示例,其中包含 2 列、日期和时间吗?
我尝试过以下方法:
<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">
另外:
<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">
但似乎没有任何效果。已经过去两天了,我阅读了大量的文档和报告,但我在任何地方都找不到有效的示例。
编辑:
我现在面临着程序员职业生涯中最奇怪的问题:网格现在可以与 DateTextBox 和 TimeTextBox 一起正常工作(这种情况适用于 Firefox 3.6.6 和 3.6.14pre、Internet Explorer 8 和 Google Chrome。),除了对于以下内容:
在 Firefox 3.6.13 中,网格中的项目数为偶数,当我尝试编辑一个元素的时间或日期时,小部件框出现在左上角,日期未正确选择,并且浏览器CPU 达到 100% 时崩溃。
但是,如果项目数量为奇数,则日期和时间的编辑效果很好。我完全不知道该怎么做,所以请提出一些想法。
最佳答案
您可以将网格中的值保留为日期类型,但使用您自定义的格式...网格将负责排序...无需为某些简单字段(例如日期)编写自定义排序... .. ......
var yourLayout = [[
{ 'name': 'Date', 'field': 'dateCol', 'width': '15%', 'formatter': this.formatDate}
]];
............
formatDate: function(dateValue) {
return dojoLocale.format(dateValue, { selector: 'date', formatLength: 'long' });
}
……
关于带有日期和时间的 Dojo 数据网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4874381/