Feb 24, 2017, 2:11 AM
[CLOSED] Change cell background color in a grid
Hi,
I need to change background color of cell in a grid, based on the if another cell data.
I refer to this thread, but seems it is doesn't work with EXT.Net version 4.x
Can i have your help?
here is my sample code using the Renderer.
I need to change background color of cell in a grid, based on the if another cell data.
I refer to this thread, but seems it is doesn't work with EXT.Net version 4.x
Can i have your help?
here is my sample code using the Renderer.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Store1.DataSource = new object[]
{
new object[] {"Test"},
new object[] {"1"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"1"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"},
new object[] {"Test"}
};
this.Store1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var RenderColor = function (value, meta, record) {
var color = 'red';
if (!record.data['TestCell'] == 1) {
color = 'green';
}
//or can set css tyle to meta.css
meta.attr = 'style="background-color:' + color + ';"';
return value;
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<form id="form1" runat="server">
<ext:Store ID="Store1"
runat="server"
IgnoreExtraFields="false"
PageSize="100">
<Model>
<ext:Model ID="mdlDDModel" runat="server">
<Fields>
<ext:ModelField Name="TestCell" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel
ID="GridPanel1"
runat="server"
StoreID="Store1"
StripeRows="true"
ClicksToEdit="1"
Title="Test Grid"
Width="600"
Height="350"
AutoExpandColumn="TestCell">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ColumnID="TestCell" Header="TestCell" DataIndex="TestCell">
</ext:Column>
<ext:Column ColumnID="ColorCell" Header="Color" DataIndex="ColorCell">
<Renderer Fn="RenderColor" />
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>
Last edited by fabricio.murta; Mar 24, 2017 at 3:48 PM.
Reason: No user feedback in 7+ days