jqGrid のカスタム フォーマッタ オプション「unformat」は、関数を指定すると機能しません。
このオプションに機能を提供しています。 カスタムフォーマッタの例 は機能すると思われますが、機能していません。
unformat 関数を使用する主な目的は、colModel に提供された unformat と formatter を呼び出す sort 関数 (並べ替え可能な列ヘッダーをクリックして並べ替えるとき) に適切な値を与えることです。
これが私のコードです(すべてのモジュールはjquery UIとjqgridに含まれています。)
<link href="../css/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css"/>
<link href="../css/ui.jqgrid.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../js/jquery-1.5.2.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript" src="../js/jquery.jqGrid.min.js"></script>
$("#GridTable").jqGrid({
datatype: "local",
colNames: ['id', 'col1', 'col2', 'col3', 'col4'],
colModel: [{name:'id',index:'id', align:'left', width:'260px'},
{name:'col1',index:'col1', width:'170px'},
{name:'col2',index:'col2', width:'160px'},
{name:'col3',index:'col3', sorttype:'float', width:'110px',unformat: unformatterFunction, formatter: formatterFunction },
{name:'col4',index:'col4', sorttype:'float', width:'110px'}
],
altRows: true,
caption: "Test Data",
height: '100%',
autowidth : true,
shrinkToFit: true,
});
function unformatterFunction(cellvalue, options, rowObject){
if(cellvalue=="-"){
return "0";
}
return cellvalue;
}
function formatterFunction(cellvalue, options, rowObject){
if(cellvalue > 15){
return "-";
}
return cellvalue;
}
grid.base.js への呼び出しを追跡するために多くの時間を費やしましたが、行ごとに unformatFunction が呼び出される jquery.fmatter.js に行く方法が見つかりませんでした。私の疑問は、並べ替え中に unformatFunction が呼び出されないことです。
exampleを編集して確認したところ、動作していません。何かがひどく間違っています。私は間違いを考えることはできません。colModel で指定された unformat 関数を呼び出さないでください。