[CLOSED] Unable to change grid cell attributes

  1. #1

    [CLOSED] Unable to change grid cell attributes

    Hi

    The following code selects the cell in a grid via data returned from the Controller - I've checked, it does point to the required cell:

    var cell = masterAccountRelatedAddressesGridPanel.getView().getCell(index, errors[i].Column);
    The following code is an attempt to change some of the Cell attributes, though ultimately we want to set the cell to 'invalid':

    cell.style.setAttribute("borderBottomColor", "red");
    cell.style.setAttribute("borderTopColor", "red");
    cell.style.setAttribute("borderRightColor", "red");
    cell.style.setAttribute("borderLeftColor", "red");
    masterAccountRelatedAddressesGridPanel.getView().refreshRow(index);
    It has no apparent effect. How do we change the attributes of a Grid Cell and/or change it to 'Invalid'?

    Thanks
    Last edited by Daniil; May 31, 2011 at 10:46 AM. Reason: [CLOSED]
  2. #2
    Hi,

    .refreshRow() discards the changes. This method totally rerenders row, so, it doesn't know anything about the attributes you set.

    I'd suggest you to use respective Column's Renderer.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    .refreshRow() discards the changes. This method totally rerenders row, so, it doesn't know anything about the attributes you set.

    I'd suggest you to use respective Column's Renderer.
    Okay, so there's no way to easily change a cell's attributes using, for example, setAttribute() ?
  4. #4
    Well, it's easy way to change, but these changes are discarded during row or whole grid refreshing.
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, it's easy way to change, but these changes are discarded during row or whole grid refreshing.
    Yes, but I've tried it without refreshing and by re-rendering instead and nothing seems to make a difference. Is it possible to change attributes directly?
  6. #6
    Quote Originally Posted by GLD View Post
    by re-rendering instead
    Not sure what you mean. Please clarify.
  7. #7
    Quote Originally Posted by GLD View Post
    Is it possible to change attributes directly?
    Possible. But I believe
    cell.style.setAttribute("borderLeftColor", "red");
    doesn't make sense with <td> element.

    For example, the following makes sense.
    cell.setAttribute('BGCOLOR', 'red');
    Anyway, if you want to change it that way, I'd suggest the following. But, repeat myself, this will be discarded during grid refreshing. Please note that grid refreshing very often occurs - sorting, filtering, paging, etc.
  8. #8
    Quote Originally Posted by GLD View Post
    Is it possible to change attributes directly?
    Possible. But I believe
    cell.style.setAttribute("borderLeftColor", "red");
    doesn't make sense with <td> element.

    For example, the following makes sense.
    cell.setAttribute('BGCOLOR', 'red');
    Anyway, if you want to change it that way, I'd suggest the following. But, repeat myself, this will be discarded during grid refreshing. Please note that grid refreshing very often occurs - sorting, filtering, paging, etc.

    Example
    <%@ 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)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <style type="text/css">
            .error div {
                border: 1px solid red;
            }
        </style>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:Button runat="server" Text="Change">
            <Listeners>
                <Click Handler="var cell = GridPanel1.view.getCell(0, 0);
                                Ext.fly(cell).addClass('error');" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Change grid cell color
    By BGeorge in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Dec 12, 2011, 5:05 AM
  2. [CLOSED] Change grid cell color on fly
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 03, 2010, 1:27 PM
  3. [CLOSED] Change the value of a grid cell
    By tms in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 15, 2010, 7:43 AM
  4. Replies: 2
    Last Post: Jun 14, 2010, 1:34 PM
  5. Change grid cell value
    By gpcontreras in forum 1.x Help
    Replies: 1
    Last Post: Feb 02, 2010, 5:24 PM

Posting Permissions