v2.0 Gridview Cell Conditional formatting

  1. #1

    v2.0 Gridview Cell Conditional formatting

    Hi, one of the differences in the example Desktop given for v1.x and v2.0 (beta) is that the colour formatting
    in the Gridview has been removed from the v2.0 example. In v1.x the "Change" and "Change %" cells were coloured either Red or Green depending on their values.

    When I installed Ext.Net v2.0 and downloaded the new desktop example it worked fine. I then tried to incorperate the colour formatting from the v1.x example but this fails with the following error "Microsoft JScript runtime error: 'template' is undefined".

    I can't figure out why it isn't working. Can you help?

    Code samples

    Client-side javascript for formatting (copied from v1.x example):
            <script type="text/javascript">
                var change = function (value) {
                    return String.format(template, (value > 0) ? "green" : "red", value);
                };
    
                var pctChange = function (value) {
                    return String.format(template, (value > 0) ? "green" : "red", value + "%");
                };
            </script>

    Grid column definition:
                                    <ext:Column runat="server" Text="Change" Width="70" Sortable="true" DataIndex="Change" >
                                        <Renderer Fn="change" />
                                    </ext:Column>
    
                                    <ext:Column runat="server" Text="% Change" Width="70" Sortable="true" DataIndex="PctChange" >
                                        <Renderer Fn="pctChange" />
                                    </ext:Column>
  2. #2
    Hi,

    You have forgot:
    var template = '<span style="color:{0};">{1}</span>';
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    You have forgot:
    var template = '<span style="color:{0};">{1}</span>';
    Oops! Yes I did. Thanks Daniil. That error has now gone but I have a new one: "Microsoft JScript runtime error: Object doesn't support this property or method"

    It appears to have a problem with "String.format". I looked at the v1.x code and could not find anything else missing. Do you have any ideas?
  4. #4
  5. #5
    Ah right, I see. It all works fine now. Apologies for wasting your time, I should have read the changelog thoroughly.

    Many thanks Daniil.
  6. #6
    No problem, we are always glad to help or push to the right direction if we can.

Similar Threads

  1. conditional Value in Column of gridpanel
    By Rupesh in forum 1.x Help
    Replies: 1
    Last Post: May 10, 2012, 10:47 AM
  2. Replies: 2
    Last Post: Nov 04, 2011, 6:06 PM
  3. GridPanel conditional edit
    By sharif in forum 1.x Help
    Replies: 1
    Last Post: Feb 20, 2010, 4:37 PM
  4. Conditional AjaxEvents
    By grmontero in forum 1.x Help
    Replies: 1
    Last Post: May 29, 2009, 10:40 AM
  5. [CLOSED] Custom styling and formatting per cell in GridPanel
    By jchau in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 24, 2009, 7:52 AM

Posting Permissions