2

いくつかの投稿を読みましたが、jqgridを初めて使用するため、まだフォローできません。5列のjqgridがありますが、最初は1列が空です。いくつかの更新を行った後、それは満たされます。

JQgridでこの行のフォントの色を変更したいので、この行が塗りつぶされている場合は、この行のフォントの色が青に変更されます。

jQuery("#list").jqGrid({
....
colModel :[ 
        {name:'prob_id', index:'prob_id', hidden:true, width:10}, 
        {name:'Model',index:'Model',width:100,editable:true,search:true,stype:'text',searchoption:{sopt:['cn']}}, 
        {name:'Serial', index:'Serial',width:80,editable:true,search:true,stype:'text',searchoptions:{sopt:['cn']}},
        {name:'Lotno', index:'Lotno', width:50, editable:true,
                 search:true,
                 stype:'text',
                 searchoption:{sopt:['cn']}},
        {name:'Detail', index:'Detail', hidden:true,width:70,formatter:myformat}
                                        ],
....

function myformat ( cellvalue, options, rowObject )
                {
                        if (!empty(cellvalue)){
                        return '<font color="blue">' + cellvalue + '</font>';//or use classes
                        } else{
                        return '<font color="black">' + cellvalue + '</font>';//or use classes
                        }
                }

詳細フィールドの値を持つすべての行のフォントの色を変更したい

しかし、エラーが発生します:

empty is not defined 

アップデート

この方法を試してください:条件を次の場所に移動することにしました:

function myformat ( cellvalue, options, rowObject )
                {
                        if (cellvalue == "closed"){
                        return '<font color="blue">' + cellvalue + '</font>';//or use classes
                        } else{
                        return '<font color="black">' + cellvalue + '</font>';//or use classes
                        }
                }

動作しますが、1列だけが青に変わるようです。条件のある行全体が必要ですCLOSED

4

1 に答える 1

3

以下のコードのようにafterInsertRowとsetRowDataを試してください

   afterInsertRow: function(rowid, rowData, rowelem) {
   var detail= rowData['Detail'];
   if(detail=="Closed"){
$(this).jqGrid('setRowData', rowid, false, { color: '#000' });
  }else {
$(this).jqGrid('setRowData', rowid, false, { color: '#FF0000' });
    }
    },

gridView:trueを削除します(gridViewがtrueの場合、afterInsertRowは機能しません)

于 2013-02-18T04:07:38.383 に答える