2013-02-25 65 views
1

如何在數據網格中同時顯示兩個我的布爾型字段? 例如:我想在網格的第1行和第2行顯示「True」「False」?但網格將由JSON加載。使用EASYUI和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); } 

,但我想使這個動態。

+1

張貼您使用的代碼。 – 2013-02-25 09:10:19

+1

<表ID = 「tblDirection」> 方向 函數RefreshDirection(){ $('#tblDirection')。empty(); data = [{id:0,name:'Uni Directional'},{id:1,name:'Bi Directional'}]; data = {「total」:「」+ data.length +「」,「rows」:data}; $('#tblDirection')。datagrid('loadData',data); } 但我想動態地做到這一點。 – Turjo 2013-02-26 04:14:05

回答

0

您可以使用格式化的複選框字段使用類型,而不是=複選框如下,

//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);>"; 
}