我只想在使用CheckColumn的网格面板中绑定数据。如果为'true'则需要检查复选框,如果为'false'则需要检查。我不知道该怎么做。我需要你的帮助。我需要一个简单的例子。
答案 0 :(得分:0)
你不需要做任何特殊的事情。只需将列描述为Check Column并绑定数据,这里是简单的例子
<ext:GridPanel runat="server" ID="grd" Height="300" Layout="FitLayout">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="data0"></ext:ModelField>
<ext:ModelField Name="data1"></ext:ModelField>
<ext:ModelField Name="data2"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="data0" Text="data0"></ext:Column>
<ext:Column ID="Column2" runat="server" DataIndex="data1" Text="data1"></ext:Column>
<ext:CheckColumn runat="server" DataIndex="data2" Text="data2"></ext:CheckColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
和代码背后;
public partial class TestCase : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//grd.GetStore().DataSource = GetData();
//grd.DataBind(); //OR with linq,
var Linqdata = from dt in GetData() select dt;
grd.GetStore().DataSource = Linqdata;
grd.DataBind();
}
private object[] GetData()
{
return new object[] {
new object[] { "test1", "test1", true },
new object[] { "test2", "test2", false },
new object[] { "test3", "test3", false } };
}
}