【发布时间】:2011-04-06 20:16:13
【问题描述】:
当我将 [ sorttype: "datetime", datefmt: "d/m/Y H:i:s" ] 设置为 jQuery 网格时,在对日期时间列进行排序时收到消息错误。
消息是:undefined。但是,这只发生在 IE 8/9 中,在 Firefox 上可以正常工作。
我有一些动态创建的表。创建的一张表是这样的:
<table id="files_1">
<thead>
<tr>
<th>Sequencial</th>
<th>File</th>
<th>Datetime</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>File 1</td>
<td>07/04/2011 09:28:00</td>
<td>100</td>
</tr>
<tr>
<td>2</td>
<td>File 2</td>
<td>07/03/2011 09:28:00</td>
<td>101</td>
</tr>
</tbody>
</table>
之后是这样的javascript函数:
$(document).ready(function() {
tableToGrid("#files_1", {
height: 'auto',
width: '100%',
rowNum: '2',
rowTotal: '2',
hoverrows: true,
colNames: ['', 'File', 'Datetime', 'Size (bytes)'],
colModel: [
{name:'Sequencial', index:'Sequencial', width: '30', stype:'text', align: 'center', sorttype:'number'},
{name:'File', index:'File', width: '370', stype:'text', align: 'left'},
{name:'Datetime', index:'Datetime', width: '', stype:'text', align: 'center', datefmt: "d/m/Y H:i:s", sorttype: 'date'},
{name:'Size', index:'Size', width: '', stype:'text', align: 'center', sorttype:'number'},
]
});
});
网格已创建并且工作正常。
它对除日期时间列之外的所有列进行排序。
当我尝试对该列进行排序(在 IE 8 或 IE 9 中)时,它会从网格返回一条漂亮的短消息(未定义),而不是 javascript 错误。就好像网格在排序时无法获取某些元素/属性。
【问题讨论】:
-
您将哪些数据用于网格?你如何填充网格?你用
formatter:'date'吗?可以用来复现问题的完整代码示例是最好的。 -
你应该修改你的原始问题并附加任何需要的信息,而不是在他自己的问题上写答案。它使您的问题的阅读变得更加容易。此外,如果您希望有人阅读,您应该以@Oleg 开头写评论(有关详细信息,请参阅here)
标签: jquery datetime sorting jqgrid