5
、私は次のコードを持っている:jqgrid数フォーマッタの使用
formatter: {
number: { decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 4, defaultValue: '0.0000' }
},
と私のcolModel中を私は持っている:
{ name: 'SalesPrice', index: 'SalesPrice', width: 90, align: 'left', formatter:'number', editable: true, editoptions:
{
readonly: true
}
}
を私のデータ型が
"ローカル" に設定されています私が最初にフォームを表示するとき、私は望んでいたように "0.00"でなく "0.0000"を取得します。さらに、インライン編集モードでは、SalesPrice値はグリッド内の他のセルに応じて変化します。更新後、SalesPrice値は整数として表示されます。
私は間違っていますか?
EDIT:より完全なコード
$("#customerOrderLineList").jqGrid({
// url: 'someUrl',
datatype: 'local',
formatter: {
number: { decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 4, defaultValue: '0.0000' }
},
// mtype: 'POST',
colNames: [ 'Part Number', 'Sales Price'],
colModel: [
{ name: 'PartNumber', index: 'PartNum', width: 90, align: 'left', editable: true, editoptions:
{
dataInit: function (el) {
$(el).autocomplete({
source: "Autocomplete",
minLength: 1
});
}
}
},
{ name: 'SalesPrice', index: 'SalesPrice', width: 90, align: 'left', formatter: 'number',
formatoptions: { decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 4, defaultValue: '0.0000' }, editable: true, editoptions:
{
readonly: true
}
}
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortable: true,
sortname: 'PartNum',
sortorder: "asc",
viewrecords: true,
imgpath: '',
autowidth: true,
onSelectRow: function (id, status) {
if (id && id !== lastsel) {
$('#customerOrderLineList').jqGrid('restoreRow', lastsel);
$('#customerOrderLineList').jqGrid('editRow', id, true);
lastsel = id;
}
},
caption: 'Caption'
});
私はここの例ではhttp://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatterでした。基本的には、特定の列ではなくグリッド全体のフォーマッタを宣言していました。与えられた例を使用して、グリッドの初期荷重に作用します。しかし、SalesPriceの値が変わると、私はまだ整数を返します。 OP – DavidS
のコードを更新します。SalesPriceアップデートの問題は、 "3"として渡された値が "3.000"として "フォーマット"されることを期待していたかもしれませんが、フォーマットとは関係ありませんでした。しかし、私はこの問題の解決策を見つけました。だから、私がフォーマッタに持っている唯一の未解決の問題は、フォーマッタをグローバルに宣言することが期待どおりに機能していないように見えるという事実に関連しています。たぶん私は間違っています。 – DavidS
@DavidS:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatterの情報を誤解しています。言語固有のファイル、例えばgrid.locale-en.jsは、 '$ .jgrid.formatter.number'を含む多くのプロパティを持つ' $ .jgrid'オブジェクトを定義します。たとえば、 '$ .jgrid.formatter.number.decimalPlaces = 4;を設定することができます。 $ .jgrid.formatter.number.defaultValue: '$( "customerOrderLineList")の前に' 0.0000 '; 'jqGrid({...});'。設定を上書きすることはできますが、jqGridの 'formatter'パラメータはありません。 – Oleg