﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Fri, 07 Jan 2011 10:42:32 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;Tyr using CSS instead of directly modifying the cell background color style. Here is the snippet:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;    .CustomRowColor&lt;br /&gt;    {&lt;br /&gt;        background-color: "#DC143C" !important;&lt;br /&gt;    }&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;/pre&gt;&lt;p&gt;Instead of:&lt;/p&gt;&lt;pre&gt;cell.style.setAttribute("backgroundColor", "Red", true);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Try:&lt;/p&gt;&lt;pre&gt;cell.className &amp;#43;= " CustomRowColor";&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This is on the right track. However, it might be necessary to remove that style. Here's a quick function that allows the adding/removing of a particular CSS to satisfy this problem.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Thanks for your help!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;pre&gt;function WebGrid_SetRowCSS(gridID, row, css, addCSS) 
{
    var returnVal = false;

    try 
    {    
        // Set row's CSS
        if (row == null) { return false; }
        var rowCells = row.GetCells();
        if (rowCells == null) { return false; }

        // Get grid
        var grid = WebGrid_GetGrid(gridID);
        if (grid == null) { return false; }

        // Check if adding or removing CSS
        // NOTE: Assume adding
        if (typeof (addCSS) == "undefined") { addCSS = true; }
        
        // Get table's column length and starting position (Check Grouped Columns)
        var columnLength = grid.RootTable.Columns.length;
        indexNumber = (grid.RootTable.GroupedColumns.length &amp;gt; 0) ? 2 : 1;        
        var rowObject = row;
        if (rowObject.Type.toUpperCase() != "GROUPHEADER") 
        {
            for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;)
            {
                var rowElement = rowObject.RowElement;
                if (rowElement != null) 
                {
                    var cell = rowElement.cells[i];
                    if (cell != null) 
                    {
                        // Set/Remove CSS
                        // NOTE: Only set CSS if it doesn't already exist
                        var cellCSS = cell.className;
                        if (addCSS == true)
                        {
                            if (cellCSS.match(css) == null)
                            {
                                cell.className &amp;#43;= " " &amp;#43; css;
                            }
                        }
                        else 
                        {
                            cell.className = cellCSS.replace(css, "");
                        }                          
                    }
                }
            }
        }
        
        returnVal = true;
    }
    catch (ex) { ShowJSException(ex); returnVal = false; }

    return returnVal;
}&lt;/pre&gt;
</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Thu, 06 Jan 2011 22:47:22 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;Tyr using CSS instead of directly modifying the cell background color style. Here is the snippet:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;    .CustomRowColor&lt;br /&gt;    {&lt;br /&gt;        background-color: "#DC143C" !important;&lt;br /&gt;    }&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;/pre&gt;&lt;p&gt;Instead of:&lt;/p&gt;&lt;pre&gt;cell.style.setAttribute("backgroundColor", "Red", true);&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Try:&lt;/p&gt;&lt;pre&gt;cell.className &amp;#43;= " CustomRowColor";&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Thu, 06 Jan 2011 09:18:13 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;I proprose applying a custom attribute during the WebGrid_SetRowBackgroundColor and re-apply the custom style during the AfterExitEditMode if the custom attribute exist.&lt;br /&gt;&lt;br /&gt;I also found an alternative if you do not wish to have the modified row style in the Grid at all, you could just disable it in the BatchUpdate settings. &lt;br /&gt;&lt;pre&gt;&amp;lt;BatchUpdateSettings HighlightChanges="false" /&amp;gt;&lt;/pre&gt;This way, you do not have to implement the AfterExitEditMode event handler.&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I don't see how making ANY changes within the AfterExitEditMode event will work given the background color is changed after? I provided sample code above to prove that.&lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Wed, 05 Jan 2011 22:50:14 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>I proprose applying a custom attribute during the WebGrid_SetRowBackgroundColor and re-apply the custom style during the AfterExitEditMode if the custom attribute exist.&lt;br /&gt;&lt;br /&gt;I also found an alternative if you do not wish to have the modified row style in the Grid at all, you could just disable it in the BatchUpdate settings. &lt;br /&gt;&lt;pre&gt;&amp;lt;BatchUpdateSettings HighlightChanges="false" /&amp;gt;&lt;/pre&gt;This way, you do not have to implement the AfterExitEditMode event handler.&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Wed, 05 Jan 2011 10:01:46 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;Try adding a custom attribute in the row element during the WebGrid_SetRowBackgroundColor&lt;br /&gt;&lt;pre&gt;rowObject.RowElement.setAttribute("CustomRowColor", "customrowcolor");&lt;/pre&gt;And during the AfterExitEditMode only modify the cell color if the custom attribute is applied in the row element&lt;br /&gt;&lt;pre&gt;function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) {&lt;br /&gt;    var grid = ISGetObject(controlId);&lt;br /&gt;    var selObj = grid.GetSelectedObject();&lt;br /&gt;    var row = selObj.ToRowObject();&lt;br /&gt;    var rowCells = row.GetCells();&lt;br /&gt;&lt;br /&gt;    var columnLength = grid.RootTable.Columns.length;&lt;br /&gt;    var rowObject = row;&lt;br /&gt;&lt;br /&gt;    var rowElement = rowObject.RowElement;&lt;br /&gt;&lt;br /&gt;    if (rowElement != null &amp;amp;&amp;amp; rowElement.getAttribute("CustomRowColor") == "customrowcolor") {&lt;br /&gt;        for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {&lt;br /&gt;            var cell = rowElement.cells[i];&lt;br /&gt;            if (cell != null) { cell.style.setAttribute("backgroundColor", "Red", true); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This is the same problem as I described above. The row's background is changed by Intersoft *AFTER* the WebGrid's OnAfterExitEditMode. Therefore, the background that I changed is not persiste&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetRowBackgroundColor.aspx.cs" Inherits="SetRowBackgroundColor" %&amp;gt;
&amp;lt;%@ Register TagPrefix="iswebgrid" Namespace="ISNet.WebUI.WebGrid" Assembly="ISNet.WebUI.WebGrid" %&amp;gt;

&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &amp;gt;
&amp;lt;HTML&amp;gt;
	&amp;lt;HEAD runat=server&amp;gt;
		&amp;lt;title&amp;gt;SetRowBackgroundColor&amp;lt;/title&amp;gt;
		&amp;lt;meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"&amp;gt;
		&amp;lt;meta name="CODE_LANGUAGE" Content="C#"&amp;gt;
		&amp;lt;meta name="vs_defaultClientScript" content="JavaScript"&amp;gt;
		&amp;lt;meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"&amp;gt;
		&amp;lt;script language="javascript"&amp;gt;
		 
		    function WebGrid1_OnRowContextMenu(controlID, rowType, rowElement, menuObject) 
            {
                try 
                {
                    // Seperator
                    var separator = new WebMenuItem();
                    separator.Type = "Separator";
                    separator.Name = "wmiSeperator";
                    menuObject.Items.Add(separator);

                    var changeBackgroundColor = new WebMenuItem();
                    changeBackgroundColor.Text = "ChangeBackgroundColor";
                    changeBackgroundColor.Name = "wmiChangeBackgroundColor";
                    changeBackgroundColor.OnClick = "ChangeBackgroundColor";
                    menuObject.Items.Add(changeBackgroundColor);                              
                }
                catch (ex) { ShowJSException(ex); }
            } 
             
            function ChangeBackgroundColor()
            {
                var returnVal = false;
             
                try {
                     
                    var row = WebGrid_GetSelectedRow("WebGrid1");       
                    if (row == null) { return; }
                    
                    WebGrid_SetRowBackgroundColor("WebGrid1", row, "red"); 
                    
                    returnVal = true;
                }
                catch (ex) { ShowJSException(ex); returnVal = false; }
                
                return returnVal;
            }

            function WebGrid_GetSelectedRow(gridID) {

                try {
                    // Get selected row
                    var grid = ISGetObject(gridID);
                    if (grid == null) { return; }
                    var selObj = grid.GetSelectedObject();
                    if (selObj == null) { return; }
                    return selObj.ToRowObject();
                }
                catch (ex) { ShowJSException(ex); }
            }

            function WebGrid_SetRowBackgroundColor(gridID, row, color) {
                var returnVal = false;

                try {
                    // Set row's background color
                    if (row == null) { return false; }
                    var rowCells = row.GetCells();
                    if (rowCells == null) { return false; }

                    // Get grid
                    var grid = ISGetObject(gridID);
                    if (grid == null) { return false; }

                    // Get table's column length and starting position (Check Grouped Columns)
                    var columnLength = grid.RootTable.Columns.length;
                    if (grid.RootTable.GroupedColumns.length &amp;gt; 0) {
                        indexNumber = 2;
                    }
                    else {
                        indexNumber = 1;
                    }

                    var rowObject = row;
                    if (rowObject.Type.toUpperCase != "GROUPHEADER") {
                        for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {
                            var rowElement = rowObject.RowElement;
                            if (rowElement != null) {
                                var cell = rowElement.cells[i];
                                if (cell != null) { cell.style.setAttribute("backgroundColor", color, true); }
                            }
                        }
                    }

                    returnVal = true;
                }
                catch (ex) { ShowJSException(ex); returnVal = false; }

                return returnVal;
            }

            function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) 
            {
                var grid = ISGetObject(controlId);
                var selObj = grid.GetSelectedObject();
                var row = selObj.ToRowObject();
                var rowCells = row.GetCells();
                var columnLength = grid.RootTable.Columns.length;
                var rowObject = row;
                window.alert("WebGrid1_OnAfterExitEditMode");
                for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) 
                {
                    var rowElement = rowObject.RowElement;
                    if (rowElement != null) 
                    {
                        var cell = rowElement.cells[i];
                        if (cell != null) 
                        {
                            cell.style.setAttribute("backgroundColor", "Red", true);
                        }
                    }
                }
            }
            
		&amp;lt;/script&amp;gt;
	
	&amp;lt;/HEAD&amp;gt;
	&amp;lt;body MS_POSITIONING="GridLayout"&amp;gt;
		&amp;lt;form id="Form1" method="post" runat="server"&amp;gt;
		
			&amp;lt;iswebgrid:webgrid id=WebGrid1 runat="server" Height="279px" Width="896px" 
			DefaultStyleMode="Elegant"
                                    UseDefaultStyle="True"
			OnInitializeDataSource="WebGrid1_InitializeDataSource"&amp;gt;
                    &amp;lt;LayoutSettings AutoHeight="false" AutoWidth="false" AllowBatchUpdate="true" BatchUpdateSettings-PromptUnsavedChanges="false"
        BatchUpdateSettings-AutomaticObjectUpdate="false" AllowEdit="Yes" EditOnClick="True"
        AllowAddNew="Yes" AllowDelete="Yes" PromptBeforeDelete="true" NewRowLostFocusAction="AlwaysPrompt"
        ResetNewRowValuesOnError="True" RowHeightDefault="22px" AllowFilter="Yes" AllowSelectColumns="Yes"
        AllowSorting="Yes" HideColumnsWhenGrouped="Default" AllowExport="Yes" InProgressUIBehavior="ChangeCursorToHourGlass"
        ApplyFiltersKey="Enter" AllowColumnFreezing="Yes" ShowFilterStatus="True" PagingMode="VirtualLoad"
        VerboseEditingInformation="False" FilterBarVisible="True" PagingExportMode="ExportAllData"
        CellPaddingDefault="0" AlwaysShowHelpButton="False" VirtualPageSize="25"          
        &amp;gt;
        &amp;lt;ClientSideEvents OnRowContextMenu="WebGrid1_OnRowContextMenu" OnAfterExitEditMode="WebGrid1_OnAfterExitEditMode" /&amp;gt;
					&amp;lt;HeaderStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#ECE9D8" ForeColor="Black" Height="20px"
						Font-Size="8pt" Font-Names="Verdana" BorderColor="#ACA899"&amp;gt;
						&amp;lt;BorderSettings&amp;gt;
							&amp;lt;Left Color="White"&amp;gt;&amp;lt;/Left&amp;gt;
							&amp;lt;Top Color="White"&amp;gt;&amp;lt;/Top&amp;gt;
						&amp;lt;/BorderSettings&amp;gt;
					&amp;lt;/HeaderStyle&amp;gt;
					&amp;lt;FrameStyle BackColor="#F1EFE2"&amp;gt;&amp;lt;/FrameStyle&amp;gt;
					&amp;lt;GroupByBox&amp;gt;
						&amp;lt;LabelStyle BorderStyle="Solid" BorderWidth="1px" BackColor="White" Font-Size="8pt" Font-Names="Verdana"
							BorderColor="Navy"&amp;gt;&amp;lt;/LabelStyle&amp;gt;
						&amp;lt;Style BackColor="Gray"&amp;gt;
						&amp;lt;/Style&amp;gt;
					&amp;lt;/GroupByBox&amp;gt;
					&amp;lt;EditTextboxStyle BorderStyle="None" BorderWidth="0px" Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/EditTextboxStyle&amp;gt;
					&amp;lt;NewRowStyle BackColor="White" ForeColor="DarkGray" Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/NewRowStyle&amp;gt;
					&amp;lt;FocusCellStyle BorderStyle="Solid" BorderWidth="1px" BorderColor="Navy"&amp;gt;&amp;lt;/FocusCellStyle&amp;gt;
					&amp;lt;RowStyle CustomRules="text-overflow: ellipsis; overflow-x: hidden" BackColor="White" Font-Size="8pt"
						Font-Names="Verdana"&amp;gt;&amp;lt;/RowStyle&amp;gt;
					&amp;lt;GroupRowInfoStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#F1EFE2" Font-Size="8pt" Font-Names="Verdana"
						BorderColor="White"&amp;gt;
						&amp;lt;BorderSettings&amp;gt;
							&amp;lt;Bottom Color="Silver"&amp;gt;&amp;lt;/Bottom&amp;gt;
							&amp;lt;Right Color="Silver"&amp;gt;&amp;lt;/Right&amp;gt;
						&amp;lt;/BorderSettings&amp;gt;
					&amp;lt;/GroupRowInfoStyle&amp;gt;
					&amp;lt;SelectedRowStyle BackColor="LightSteelBlue"&amp;gt;&amp;lt;/SelectedRowStyle&amp;gt;
					&amp;lt;AlternatingRowStyle CustomRules="text-overflow: ellipsis; overflow-x: hidden" BackColor="AntiqueWhite"
						Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/AlternatingRowStyle&amp;gt;
					&amp;lt;StatusBarStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#ECE9D8" Font-Size="8pt" Font-Names="Verdana"
						BorderColor="#ACA899"&amp;gt;
						&amp;lt;Padding Bottom="2px" Left="2px" Top="2px" Right="2px"&amp;gt;&amp;lt;/Padding&amp;gt;
					&amp;lt;/StatusBarStyle&amp;gt;
					&amp;lt;StatusBarCommandStyle&amp;gt;
						&amp;lt;Over BorderWidth="1px" BorderColor="Navy" BorderStyle="Solid" BackColor="CornflowerBlue"&amp;gt;&amp;lt;/Over&amp;gt;
						&amp;lt;Normal&amp;gt;
							&amp;lt;Padding Bottom="1px" Left="1px" Top="1px" Right="1px"&amp;gt;&amp;lt;/Padding&amp;gt;
						&amp;lt;/Normal&amp;gt;
						&amp;lt;Active BackColor="RoyalBlue" BaseStyle="Over"&amp;gt;&amp;lt;/Active&amp;gt;
					&amp;lt;/StatusBarCommandStyle&amp;gt;
					&amp;lt;PreviewRowStyle ForeColor="#0000C0"&amp;gt;&amp;lt;/PreviewRowStyle&amp;gt;
				&amp;lt;/LayoutSettings&amp;gt;
				&amp;lt;RootTable DataKeyField="CustomerID" Caption="Customers" GridLineStyle="NotSet"&amp;gt;
					&amp;lt;Columns&amp;gt;
					        &amp;lt;ISWebGrid:WebGridColumn Caption="Portfolio Name" Name="PortfolioNameList"  
                                                DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit"
                                                FilterEditType="TextBox" Width="100px"&amp;gt;
                                            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Address" DataMember="Address" Name="Address" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						 
					 &amp;lt;ISWebGrid:WebGridColumn Caption=" " Name="AddPortfolio" DataMember=""
                        ButtonText="Add Portfolio" DataType="System.String" ColumnType="Template" EditType="NoEdit"
                        NewRowEditType="SameAsEditType" FilterEditType="NoEdit" Width="65px"&amp;gt;
                        &amp;lt;ButtonStyle BackColor="AliceBlue"&amp;gt;
                            &amp;lt;Padding Top="2px" Left="1px" Right="1px" Bottom="1px" /&amp;gt;
                        &amp;lt;/ButtonStyle&amp;gt;
                        &amp;lt;CellTemplate&amp;gt;
                            &amp;lt;img runat="server" id="imgPortfolio"  alt="Manage this treaty's portfolios"
                                border="0" style="padding-top: 1px;"  
                             /&amp;gt;
                        &amp;lt;/CellTemplate&amp;gt;
                    &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
                    
                &amp;lt;iswebgrid:WebGridColumn Caption="City" DataMember="City" Name="City" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="CompanyName" DataMember="CompanyName" Name="CompanyName" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="ContactName" DataMember="ContactName" Name="ContactName" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="ContactTitle" DataMember="ContactTitle" Name="ContactTitle" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Country" DataMember="Country" Name="Country" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="CustomerID" DataMember="CustomerID" Name="CustomerID" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Fax" DataMember="Fax" Name="Fax" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Phone" DataMember="Phone" Name="Phone" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="PostalCode" DataMember="PostalCode" Name="PostalCode" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Region" DataMember="Region" Name="Region" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
					&amp;lt;/Columns&amp;gt;
				&amp;lt;/RootTable&amp;gt;
			&amp;lt;/iswebgrid:webgrid&amp;gt;
			 
		&amp;lt;/form&amp;gt;
	&amp;lt;/body&amp;gt;
&amp;lt;/HTML&amp;gt;
&lt;/pre&gt;
</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Tue, 04 Jan 2011 23:52:48 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>Try adding a custom attribute in the row element during the WebGrid_SetRowBackgroundColor&lt;br /&gt;&lt;pre&gt;rowObject.RowElement.setAttribute("CustomRowColor", "customrowcolor");&lt;/pre&gt;And during the AfterExitEditMode only modify the cell color if the custom attribute is applied in the row element&lt;br /&gt;&lt;pre&gt;function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) {&lt;br /&gt;    var grid = ISGetObject(controlId);&lt;br /&gt;    var selObj = grid.GetSelectedObject();&lt;br /&gt;    var row = selObj.ToRowObject();&lt;br /&gt;    var rowCells = row.GetCells();&lt;br /&gt;&lt;br /&gt;    var columnLength = grid.RootTable.Columns.length;&lt;br /&gt;    var rowObject = row;&lt;br /&gt;&lt;br /&gt;    var rowElement = rowObject.RowElement;&lt;br /&gt;&lt;br /&gt;    if (rowElement != null &amp;amp;&amp;amp; rowElement.getAttribute("CustomRowColor") == "customrowcolor") {&lt;br /&gt;        for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {&lt;br /&gt;            var cell = rowElement.cells[i];&lt;br /&gt;            if (cell != null) { cell.style.setAttribute("backgroundColor", "Red", true); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Tue, 04 Jan 2011 09:58:25 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;By default in BatchUpdate mode the WebGrid will apply a style for modified row. This style is applied by setting the cell attribute, which will override the style you already applied. My previous post suggestion is to override this default style during the AfterExitEditMode event handler with the style you already defined.&lt;/p&gt;&lt;p&gt;In order to integrate the RowContextMenu and AfterExitEditMode method, you could assign a custom attribute to the row in RowContextMenu, for example CustomColor='CustomColor', in the AfterExitEditMode event handler you only assigned the Red color to the row which has the CustomColor attribute.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Can you explain this a bit more?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Sun, 02 Jan 2011 23:08:45 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;By default in BatchUpdate mode the WebGrid will apply a style for modified row. This style is applied by setting the cell attribute, which will override the style you already applied. My previous post suggestion is to override this default style during the AfterExitEditMode event handler with the style you already defined.&lt;/p&gt;&lt;p&gt;In order to integrate the RowContextMenu and AfterExitEditMode method, you could assign a custom attribute to the row in RowContextMenu, for example CustomColor='CustomColor', in the AfterExitEditMode event handler you only assigned the Red color to the row which has the CustomColor attribute.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Thu, 30 Dec 2010 11:05:13 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;blockquote&gt;&lt;p&gt;In such scenario, you will need to re-apply the change background color logic in the AfterExitEditMode client side event handler. By default the WebGrid will apply the edited row with a predefined style. Here is the snippet to changed the background color during AfterExitEditMode event handler:&lt;/p&gt;&lt;pre&gt;function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) {&lt;br /&gt;    var grid = ISGetObject(controlId);&lt;br /&gt;    var selObj = grid.GetSelectedObject();&lt;br /&gt;    var row = selObj.ToRowObject();&lt;br /&gt;    var rowCells = row.GetCells();&lt;br /&gt;&lt;br /&gt;    var columnLength = grid.RootTable.Columns.length;&lt;br /&gt;    var rowObject = row;&lt;br /&gt;    for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {&lt;br /&gt;        var rowElement = rowObject.RowElement;&lt;br /&gt;        if (rowElement != null) {&lt;br /&gt;            var cell = rowElement.cells[i];&lt;br /&gt;            if (cell != null) { cell.style.setAttribute("backgroundColor", "Red", true); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This won't fix the problem because the cell edit that fires the OnAfterExitEditMode event occurs BEFORE the RowContextMenu's function fires.  I don't understand what is then causing the row's background to be set back given the RowContextMenu's function is setting the background to red?&lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Wed, 29 Dec 2010 22:06:18 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;In such scenario, you will need to re-apply the change background color logic in the AfterExitEditMode client side event handler. By default the WebGrid will apply the edited row with a predefined style. Here is the snippet to changed the background color during AfterExitEditMode event handler:&lt;/p&gt;&lt;pre&gt;function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) {&lt;br /&gt;    var grid = ISGetObject(controlId);&lt;br /&gt;    var selObj = grid.GetSelectedObject();&lt;br /&gt;    var row = selObj.ToRowObject();&lt;br /&gt;    var rowCells = row.GetCells();&lt;br /&gt;&lt;br /&gt;    var columnLength = grid.RootTable.Columns.length;&lt;br /&gt;    var rowObject = row;&lt;br /&gt;    for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {&lt;br /&gt;        var rowElement = rowObject.RowElement;&lt;br /&gt;        if (rowElement != null) {&lt;br /&gt;            var cell = rowElement.cells[i];&lt;br /&gt;            if (cell != null) { cell.style.setAttribute("backgroundColor", "Red", true); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Problem changing the row cells background color</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Problem-changing-the-row-cells-background-color/</link><pubDate>Wed, 29 Dec 2010 16:10:13 GMT</pubDate><dc:creator>SAgosto</dc:creator><description>&lt;p&gt;I am having a problem changing the row cells background color. To reproduce, right click on a row and click the ChangeBackGroundColor menu item. After the row loses focus, you will notice the row's background is red. However, if you make a change to one of the editable cells and then right click the row to click the ChangeBackGroundColor menu item, the row doesn't change background color after the row loses focus.  How do I fix?&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="SetRowBackgroundColor.aspx.cs" Inherits="SetRowBackgroundColor" %&amp;gt;
&amp;lt;%@ Register TagPrefix="iswebgrid" Namespace="ISNet.WebUI.WebGrid" Assembly="ISNet.WebUI.WebGrid" %&amp;gt;

&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &amp;gt;
&amp;lt;HTML&amp;gt;
	&amp;lt;HEAD runat=server&amp;gt;
		&amp;lt;title&amp;gt;SetRowBackgroundColor&amp;lt;/title&amp;gt;
		&amp;lt;meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"&amp;gt;
		&amp;lt;meta name="CODE_LANGUAGE" Content="C#"&amp;gt;
		&amp;lt;meta name="vs_defaultClientScript" content="JavaScript"&amp;gt;
		&amp;lt;meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"&amp;gt;
		&amp;lt;script language="javascript"&amp;gt;
		 
		    function WebGrid1_OnRowContextMenu(controlID, rowType, rowElement, menuObject) 
            {
                try 
                {
                    // Seperator
                    var separator = new WebMenuItem();
                    separator.Type = "Separator";
                    separator.Name = "wmiSeperator";
                    menuObject.Items.Add(separator);

                    var changeBackgroundColor = new WebMenuItem();
                    changeBackgroundColor.Text = "ChangeBackgroundColor";
                    changeBackgroundColor.Name = "wmiChangeBackgroundColor";
                    changeBackgroundColor.OnClick = "ChangeBackgroundColor";
                    menuObject.Items.Add(changeBackgroundColor);                              
                }
                catch (ex) { ShowJSException(ex); }
            } 
             
            function ChangeBackgroundColor()
            {
                var returnVal = false;
             
                try {
                     
                    var row = WebGrid_GetSelectedRow("WebGrid1");       
                    if (row == null) { return; }
                    
                    WebGrid_SetRowBackgroundColor("WebGrid1", row, "red"); 
                    
                    returnVal = true;
                }
                catch (ex) { ShowJSException(ex); returnVal = false; }
                
                return returnVal;
            }

            function WebGrid_GetSelectedRow(gridID) {

                try {
                    // Get selected row
                    var grid = ISGetObject(gridID);
                    if (grid == null) { return; }
                    var selObj = grid.GetSelectedObject();
                    if (selObj == null) { return; }
                    return selObj.ToRowObject();
                }
                catch (ex) { ShowJSException(ex); }
            }

            function WebGrid_SetRowBackgroundColor(gridID, row, color) {
                var returnVal = false;

                try {
                    // Set row's background color
                    if (row == null) { return false; }
                    var rowCells = row.GetCells();
                    if (rowCells == null) { return false; }

                    // Get grid
                    var grid = ISGetObject(gridID);
                    if (grid == null) { return false; }

                    // Get table's column length and starting position (Check Grouped Columns)
                    var columnLength = grid.RootTable.Columns.length;
                    if (grid.RootTable.GroupedColumns.length &amp;gt; 0) {
                        indexNumber = 2;
                    }
                    else {
                        indexNumber = 1;
                    }

                    var rowObject = row;
                    if (rowObject.Type.toUpperCase != "GROUPHEADER") {
                        for (var i = 1; i &amp;lt;= columnLength; i&amp;#43;&amp;#43;) {
                            var rowElement = rowObject.RowElement;
                            if (rowElement != null) {
                                var cell = rowElement.cells[i];
                                if (cell != null) { cell.style.setAttribute("backgroundColor", color, true); }
                            }
                        }
                    }

                    returnVal = true;
                }
                catch (ex) { ShowJSException(ex); returnVal = false; }

                return returnVal;
            }
		&amp;lt;/script&amp;gt;
	
	&amp;lt;/HEAD&amp;gt;
	&amp;lt;body MS_POSITIONING="GridLayout"&amp;gt;
		&amp;lt;form id="Form1" method="post" runat="server"&amp;gt;
		
			&amp;lt;iswebgrid:webgrid id=WebGrid1 runat="server" Height="279px" Width="896px" 
			DefaultStyleMode="Elegant"
                                    UseDefaultStyle="True"
			OnInitializeDataSource="WebGrid1_InitializeDataSource"&amp;gt;
                    &amp;lt;LayoutSettings AutoHeight="false" AutoWidth="false" AllowBatchUpdate="true" BatchUpdateSettings-PromptUnsavedChanges="false"
        BatchUpdateSettings-AutomaticObjectUpdate="false" AllowEdit="Yes" EditOnClick="True"
        AllowAddNew="Yes" AllowDelete="Yes" PromptBeforeDelete="true" NewRowLostFocusAction="AlwaysPrompt"
        ResetNewRowValuesOnError="True" RowHeightDefault="22px" AllowFilter="Yes" AllowSelectColumns="Yes"
        AllowSorting="Yes" HideColumnsWhenGrouped="Default" AllowExport="Yes" InProgressUIBehavior="ChangeCursorToHourGlass"
        ApplyFiltersKey="Enter" AllowColumnFreezing="Yes" ShowFilterStatus="True" PagingMode="VirtualLoad"
        VerboseEditingInformation="False" FilterBarVisible="True" PagingExportMode="ExportAllData"
        CellPaddingDefault="0" AlwaysShowHelpButton="False" VirtualPageSize="25"          
        &amp;gt;
        &amp;lt;ClientSideEvents OnRowContextMenu="WebGrid1_OnRowContextMenu" /&amp;gt;
					&amp;lt;HeaderStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#ECE9D8" ForeColor="Black" Height="20px"
						Font-Size="8pt" Font-Names="Verdana" BorderColor="#ACA899"&amp;gt;
						&amp;lt;BorderSettings&amp;gt;
							&amp;lt;Left Color="White"&amp;gt;&amp;lt;/Left&amp;gt;
							&amp;lt;Top Color="White"&amp;gt;&amp;lt;/Top&amp;gt;
						&amp;lt;/BorderSettings&amp;gt;
					&amp;lt;/HeaderStyle&amp;gt;
					&amp;lt;FrameStyle BackColor="#F1EFE2"&amp;gt;&amp;lt;/FrameStyle&amp;gt;
					&amp;lt;GroupByBox&amp;gt;
						&amp;lt;LabelStyle BorderStyle="Solid" BorderWidth="1px" BackColor="White" Font-Size="8pt" Font-Names="Verdana"
							BorderColor="Navy"&amp;gt;&amp;lt;/LabelStyle&amp;gt;
						&amp;lt;Style BackColor="Gray"&amp;gt;
						&amp;lt;/Style&amp;gt;
					&amp;lt;/GroupByBox&amp;gt;
					&amp;lt;EditTextboxStyle BorderStyle="None" BorderWidth="0px" Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/EditTextboxStyle&amp;gt;
					&amp;lt;NewRowStyle BackColor="White" ForeColor="DarkGray" Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/NewRowStyle&amp;gt;
					&amp;lt;FocusCellStyle BorderStyle="Solid" BorderWidth="1px" BorderColor="Navy"&amp;gt;&amp;lt;/FocusCellStyle&amp;gt;
					&amp;lt;RowStyle CustomRules="text-overflow: ellipsis; overflow-x: hidden" BackColor="White" Font-Size="8pt"
						Font-Names="Verdana"&amp;gt;&amp;lt;/RowStyle&amp;gt;
					&amp;lt;GroupRowInfoStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#F1EFE2" Font-Size="8pt" Font-Names="Verdana"
						BorderColor="White"&amp;gt;
						&amp;lt;BorderSettings&amp;gt;
							&amp;lt;Bottom Color="Silver"&amp;gt;&amp;lt;/Bottom&amp;gt;
							&amp;lt;Right Color="Silver"&amp;gt;&amp;lt;/Right&amp;gt;
						&amp;lt;/BorderSettings&amp;gt;
					&amp;lt;/GroupRowInfoStyle&amp;gt;
					&amp;lt;SelectedRowStyle BackColor="LightSteelBlue"&amp;gt;&amp;lt;/SelectedRowStyle&amp;gt;
					&amp;lt;AlternatingRowStyle CustomRules="text-overflow: ellipsis; overflow-x: hidden" BackColor="AntiqueWhite"
						Font-Size="8pt" Font-Names="Verdana"&amp;gt;&amp;lt;/AlternatingRowStyle&amp;gt;
					&amp;lt;StatusBarStyle BorderStyle="Solid" BorderWidth="1px" BackColor="#ECE9D8" Font-Size="8pt" Font-Names="Verdana"
						BorderColor="#ACA899"&amp;gt;
						&amp;lt;Padding Bottom="2px" Left="2px" Top="2px" Right="2px"&amp;gt;&amp;lt;/Padding&amp;gt;
					&amp;lt;/StatusBarStyle&amp;gt;
					&amp;lt;StatusBarCommandStyle&amp;gt;
						&amp;lt;Over BorderWidth="1px" BorderColor="Navy" BorderStyle="Solid" BackColor="CornflowerBlue"&amp;gt;&amp;lt;/Over&amp;gt;
						&amp;lt;Normal&amp;gt;
							&amp;lt;Padding Bottom="1px" Left="1px" Top="1px" Right="1px"&amp;gt;&amp;lt;/Padding&amp;gt;
						&amp;lt;/Normal&amp;gt;
						&amp;lt;Active BackColor="RoyalBlue" BaseStyle="Over"&amp;gt;&amp;lt;/Active&amp;gt;
					&amp;lt;/StatusBarCommandStyle&amp;gt;
					&amp;lt;PreviewRowStyle ForeColor="#0000C0"&amp;gt;&amp;lt;/PreviewRowStyle&amp;gt;
				&amp;lt;/LayoutSettings&amp;gt;
				&amp;lt;RootTable DataKeyField="CustomerID" Caption="Customers" GridLineStyle="NotSet"&amp;gt;
					&amp;lt;Columns&amp;gt;
					        &amp;lt;ISWebGrid:WebGridColumn Caption="Portfolio Name" Name="PortfolioNameList"  
                                                DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit"
                                                FilterEditType="TextBox" Width="100px"&amp;gt;
                                            &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Address" DataMember="Address" Name="Address" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						 
					 &amp;lt;ISWebGrid:WebGridColumn Caption=" " Name="AddPortfolio" DataMember=""
                        ButtonText="Add Portfolio" DataType="System.String" ColumnType="Template" EditType="NoEdit"
                        NewRowEditType="SameAsEditType" FilterEditType="NoEdit" Width="65px"&amp;gt;
                        &amp;lt;ButtonStyle BackColor="AliceBlue"&amp;gt;
                            &amp;lt;Padding Top="2px" Left="1px" Right="1px" Bottom="1px" /&amp;gt;
                        &amp;lt;/ButtonStyle&amp;gt;
                        &amp;lt;CellTemplate&amp;gt;
                            &amp;lt;img runat="server" id="imgPortfolio"  alt="Manage this treaty's portfolios"
                                border="0" style="padding-top: 1px;"  
                             /&amp;gt;
                        &amp;lt;/CellTemplate&amp;gt;
                    &amp;lt;/ISWebGrid:WebGridColumn&amp;gt;
                    
                &amp;lt;iswebgrid:WebGridColumn Caption="City" DataMember="City" Name="City" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="CompanyName" DataMember="CompanyName" Name="CompanyName" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="ContactName" DataMember="ContactName" Name="ContactName" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="ContactTitle" DataMember="ContactTitle" Name="ContactTitle" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Country" DataMember="Country" Name="Country" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="CustomerID" DataMember="CustomerID" Name="CustomerID" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Fax" DataMember="Fax" Name="Fax" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Phone" DataMember="Phone" Name="Phone" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="PostalCode" DataMember="PostalCode" Name="PostalCode" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
						&amp;lt;iswebgrid:WebGridColumn Caption="Region" DataMember="Region" Name="Region" Width="100px"&amp;gt;&amp;lt;/iswebgrid:WebGridColumn&amp;gt;
					&amp;lt;/Columns&amp;gt;
				&amp;lt;/RootTable&amp;gt;
			&amp;lt;/iswebgrid:webgrid&amp;gt;
			 
		&amp;lt;/form&amp;gt;
	&amp;lt;/body&amp;gt;
&amp;lt;/HTML&amp;gt;
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>