ある場合はいくつかの列に0を表示する必要がありますDBからのデータはありません。したがって、colModelの列のデフォルト値を定義して、空の値をチェックして配列内でゼロにする必要がないようにすることは可能です。
回答:
回答№1は2列のデフォルト値を定義する直接的な方法はありませんが、何らかの方法でこれを行うことができます。
を使用して Custom Formatter
特定の列に対して独自のフォーマッタを定義できます。通常、これは関数です。その関数では、列値がnullまたは空であるかどうかを確認し、デフォルト値を返すことができます。
例えば :
<script>
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:"price", index:"price", width:60, align:"center", editable: true,
formatter:currencyFmatter},
...
]
...
});
function currencyFmatter (cellvalue, options, rowObject)
{
// do something here to check value and return default value
if(cellvalue == "" || cellvalue == "null")
return new_format_value
}
</script>