Reputation: 1
When I set [ sorttype: "datetime", datefmt: "d/m/Y H:i:s" ]
to a jQuery grid, I get a message error when sorting a datetime column.
The message is: undefined
. But, this only happens in IE 8/9, on Firefox it works fine.
I have some tables created dynamically. One table created is like this:
<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>
After this comes a javascript function like this:
$(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'},
]
});
});
The grid is created and works fine.
It sorts all the columns, except the datetime column.
When I try to sort this column (in IE 8 or IE 9) it returns a beautiful short message (undefined), from the grid, not a javascript error. It is as if the grid could not get some element/attribute while sorting.
Upvotes: 0
Views: 3255
Reputation: 204
Try use a complete date format information:
{
name:'Datetime',
index:'Datetime',
width: '',
formatter:'date',
formatoptions: {newformat:'m/d/Y'},
datefmt: 'd-M-Y',
sorttype: 'date'
}
Upvotes: 2
Reputation: 221997
There are one more simple error: comma before ] at the end of colModel
definition. The combination },]
is the syntax error.
The demo include the code which you posted and I see no errors at least in IE9.
You can additionally verify that in your version of jquery.jqGrid.min.js which you downloaded the following modules are included: grid.base.js, grid.common.js, grid.tbltogrid.js. To do this you can just open jquery.jqGrid.min.js in the text editor and search in the comment at the beginning of the file after the words "Modules:" for grid.base.js, grid.common.js, grid.tbltogrid.js.
Upvotes: 1