PDA

View Full Version : [CLOSED] Hide Checkbox Editor for Certain Rows



rthiney
Jul 23, 2013, 12:29 AM
Hi,
I have a grid in the attached picture. I want to hide the checkbox for the first row.
What is the best way to go about doing that?

Thanks,
Raphael

Baidaly
Jul 23, 2013, 2:22 AM
Hello!

You should use renderer:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, true },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, true },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, false },
new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, false }
};

this.Store1.DataBind();
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:GridPanel
runat="server"
Title="Grid"
Width="600"
Height="350">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="price" Type="Float" />
<ext:ModelField Name="change" Type="Float" />
<ext:ModelField Name="pctChange" Type="Float" />
<ext:ModelField Name="active" Type="Boolean">
</ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
<ext:Column runat="server" Text="Price" Width="75" DataIndex="price" />
<ext:Column runat="server" Text="Change" Width="75" DataIndex="change" />
<ext:Column runat="server" Text="Change" Width="75" DataIndex="pctChange" />
<ext:CheckColumn runat="server" Text="Active" Width="50" DataIndex="active">
<Renderer Handler="
if (rowIndex == 0)
return '';
if (value == true)
return '<div class=\'x-grid-checkheader x-grid-checkheader-checked\'>&nbsp;</div>';
else
return '<div class=\'x-grid-checkheader x-grid-checkheader-unchecked\'>&nbsp;</div>';
"></Renderer>
<Listeners>

</Listeners>
</ext:CheckColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

rthiney
Jul 23, 2013, 2:25 AM
Hello!

You should use renderer:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, true },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, true },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, false },
new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, false }
};

this.Store1.DataBind();
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:GridPanel
runat="server"
Title="Grid"
Width="600"
Height="350">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="price" Type="Float" />
<ext:ModelField Name="change" Type="Float" />
<ext:ModelField Name="pctChange" Type="Float" />
<ext:ModelField Name="active" Type="Boolean">
</ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
<ext:Column runat="server" Text="Price" Width="75" DataIndex="price" />
<ext:Column runat="server" Text="Change" Width="75" DataIndex="change" />
<ext:Column runat="server" Text="Change" Width="75" DataIndex="pctChange" />
<ext:CheckColumn runat="server" Text="Active" Width="50" DataIndex="active">
<Renderer Handler="
if (rowIndex == 0)
return '';
if (value == true)
return '<div class=\'x-grid-checkheader x-grid-checkheader-checked\'>&nbsp;</div>';
else
return '<div class=\'x-grid-checkheader x-grid-checkheader-unchecked\'>&nbsp;</div>';
"></Renderer>
<Listeners>

</Listeners>
</ext:CheckColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>


Worked like a charm!!!
Thanks!

rthiney
Oct 04, 2013, 2:59 PM
Worked like a charm!!!
Thanks!

I recently updated from SVN, and this no longer seems to work...any ideas?

Baidaly
Oct 04, 2013, 5:08 PM
Couldn't reproduce. Do you use the same logic and don't override any CSS rules?

6994