C# 使用EASYUI和Json创建数据网格,其中数据类型为Boolean

C# 使用EASYUI和Json创建数据网格,其中数据类型为Boolean,c#,javascript,json,asp.net-mvc-3,jquery-easyui,C#,Javascript,Json,Asp.net Mvc 3,Jquery Easyui,如何在数据网格中同时显示两个布尔字段? 示例:我想在网格的第一行和第二行显示“True”和“False”?但网格将由JSON加载 <table id="tblDirection"> <thead> <tr> <th field="ck" checkbox="true"></th> <th field="name" width="120">Direction</th

如何在数据网格中同时显示两个布尔字段? 示例:我想在网格的第一行和第二行显示“True”“False”?但网格将由JSON加载

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

但我想让它充满活力

您可以对复选框字段使用格式化程序,而不是使用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);>";
}
//html标记中的列定义
//格式化程序函数
函数formatCheckbox(值、行、索引)
{
如果(值)
返回“”;
其他的
返回“”;
}

发布您正在使用的代码。方向函数RefreshDirection(){$('#tblDirection').empty();data=[{id:0,name:'Uni-directive'},{id:1,name:'bidirective'}];data={“total”:“+data.length+”,“rows”:data};$('#tblDirection').datagrid('loadData',data);}但我想动态地实现它。
//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);>";
}