1

Data Grid で一度に両方のブール フィールドを表示するにはどうすればよいですか? 例:グリッドの 1 行目と 2 行目に"True""False"を表示したいですか? ただし、Grid は JSON によってロードされます。

<table id="tblDirection"> 
   <thead> 
     <tr> 
        <th field="ck" checkbox="true"></th> 
        <th field="name" width="120">Direction</th> 
      </tr> 
    </thead> 
</table> 

ここにJavaScriptコードがあります:

function RefreshDirection() { 
     $('#tblDirection').empty(); 
     data = [{ id: 0, name: 'Uni Directional' 
}, { id: 1, name: 'Bi Directional'}]; 
data = { "total": "" + data.length + "", "rows": data }; 
$('#tblDirection').datagrid('loadData', data); } 

しかし、私はこれを動的にしたい。

4

1 に答える 1

0

次のように type=checkbox を使用する代わりに、チェックボックス フィールドにフォーマッタを使用できます。

//column defintion in html tags
<th field="checkfieldId" width="80" formatter="formatCheckbox" >


//formatter function
function formatCheckbox(value,row,index)
{
 if(value)
    return "<input type='checkbox' checked=true onChange=checkChecked("+index+",this);>";
 else
    return "<input type='checkbox' onChange=checkChecked("+index+",this);>";
}
于 2013-02-26T16:35:41.403 に答える