Spread ASP.NET 17
Spread for ASP.NET 17 Product Documentation / Client-Side Scripting Reference / Scripting Members / Methods / SetBackColor
In This Topic
    SetBackColor
    In This Topic

    Sets the backcolor of the cell at the specified row and column.

    Syntax

    [JavaScript]

    FpSpread1.SetBackColor(row,column,value,noEvent);

    Parameters

    row
    Integer, row index
    column
    Integer, column index
    value
    String, value
    noEvent
    Boolean, whether to trigger the onDataChanged event

    Return Type

    None

    Remarks

    This method sets the color of a cell at the specified row and column and triggers the onDataChanged event if specified. If noEvent is true, the method does not trigger an event; otherwise, the method triggers an onDataChanged event. This method does not cause a postback to occur.

    Example 1

    This is a sample that contains the method.

    On the server side on page load:

    Code
    Copy Code
    FpSpread1.Attributes.Add("onDataChanged", "ProfileSpread()")
    

    On the client side, the script that contains the method would look like this:

    JavaScript
    Copy Code
    <script type="text/javascript">
           
            function ProfileSpread()
            {
                var szCell = document.all("FpSpread1");
                if (szCell.ActiveCol == 0)
                {
                    szCell.Cells(0, 1).SetBackColor("red", true);
                    alert("Test");
                }
            }
    </script>
    

    Example 2

    This example maps the onDataChanged event and updates the cell backcolor when a value is changed.

    JavaScript
    Copy Code
    <script language="javascript" type="text/javascript">
            window.onload = function () {
                var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");
         
              // IE
              if (spread1.addEventListener) {
                  // IE9
                  spread1.addEventListener("DataChanged", dataChanged, false);
              } else {
                  // Other versions of IE and IE9 quirks mode (no doctype set)
                  spread1.onDataChanged = dataChanged;
              }
         
      }
            function dataChanged() {
                var spread1 = document.getElementById("<%=FpSpread1.ClientID %>")
                spread1.Cells(FpSpread1.ActiveRow, 2).SetBackColor("red", true);
      }
    </script>