私のWebアプリケーションには、ユーザーレコードのテーブルがあります。レコードはクライアント送信時に追加および削除され、ユーザーが保存ボタンをクリックしてサーバー上で行われたすべての操作を保存します。
テーブルの並べ替え機能にテーブルソーターを適用しました。しかし、驚くべきことに、ソートされた機能はIDフィールド、つまりテーブルの最初のフィールドでのみ正常に機能しますが、他のすべてのフィールドではエラーが発生します(chromeからのエラートレース)
Uncaught TypeError: Cannot read property 'type' of undefined
multisortjquery.tablesorter.js:600
$.extend.tablesorter.construct.each.$headers.click.mousedown.onselectstart
これがテーブル構造です。
<table id="contentTable" class="tablesorter">
<thead>
<tr>
<th> ID </th>
<th> Name </th>
<th> Birth Date </th>
<th> City </th>
<th id="actionheader"> Action</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
これでは、データを動的に追加します。この状況では、ソートは最初のフィールド、つまりIDフィールドに対してのみ正常に機能します。
これが私がtableSortingを初期化した方法です。
function initializeTableSorting() {
$("#contentTable").tablesorter({
sortList : [[0, 0]],
headers : {
0 : {
sorter : "integer"
},
1 : {
sorter : "text"
},
2 : {
sorter : false
},
3 : {
sorter : "text"
},
4 : {
sorter : false
}
}
});
}
初期化からfalseオプションを削除した場合、日付フィールドでも、すべてのフィールドでこれを機能させるにはどうすればよいですか?