[CLOSED] CustomSummaryType event not firing when gridpanel column hide in Ext v2.5

  1. #1

    [CLOSED] CustomSummaryType event not firing when gridpanel column hide in Ext v2.5

    Hi,

    I have scenario like when total amount is >0 then need to show "BarterDue" column else hide the same column. Have written CustomSummaryType="renderAmountDue" method, in this method i am calculating total amount, based on this amount the same column should be show/hide. So when amount total is zero then columns are hiding, next time when the amount >0 then the column is not showing and the CustomSummaryType event also not firing.

    please give solution as early as possible.
    Thank you

    Sample Code:
    <%@ 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)
            {
                this.GridPanel1.Store.Primary.DataSource = new object[]
                {
                    new object[] { true, DateTime.Now, 1 ,0},
                    new object[] { false, DateTime.Now.AddDays(-1), 2,0 },
                    new object[] { true, DateTime.Now.AddDays(-2), 3,100 },
                    new object[] { false, DateTime.Now.AddDays(-3), 4,0 },
                    new object[] { true, DateTime.Now.AddDays(-4), 5,0 }
                    
                };
    
                this.GridPanel1.Store.Primary.DataBind();
            }
        }
        protected void ReSetData(object sender, DirectEventArgs e)
        {
            this.GridPanel1.Store.Primary.DataSource = new object[]
                {
                    new object[] { true, DateTime.Now, 1 ,0},
                    new object[] { false, DateTime.Now.AddDays(-1), 2,0 },
                    new object[] { true, DateTime.Now.AddDays(-2), 3,0 },
                    new object[] { false, DateTime.Now.AddDays(-3), 4,0 },
                    new object[] { true, DateTime.Now.AddDays(-4), 5,0 }
                    
                };
    
            this.GridPanel1.Store.Primary.DataBind();
        }
        protected void SetData(object sender,DirectEventArgs e)
        {
            this.GridPanel1.Store.Primary.DataSource = new object[]
                {
                    new object[] { true, DateTime.Now, 5 ,12.34},
                    new object[] { false, DateTime.Now.AddDays(-1), 52,0 },
                    new object[] { true, DateTime.Now.AddDays(-2), 3,56.6 },
                    new object[] { false, DateTime.Now.AddDays(-3), 2,0 },
                    new object[] { true, DateTime.Now.AddDays(-4), 1,44 }
                    
                };
    
            this.GridPanel1.Store.Primary.DataBind();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Columns Variations - Ext.NET Examples</title>
        
    
        <script language="javascript" type="text/javascript"">
            var renderAmountDue = function (records) {
                var length = records.length, total = 0;
                if (length > 0) {
                    for (var i = 0; i < length; i++) {
                        total += records[i].get("AmountDue");
                    }
    
                    if (total > 0)
                        App.BarterDue.show();
                    else
                        App.BarterDue.hide();
                    return total;
                }
            }
            
        </script>
    </head>
    <body>
        <form runat="server">
        
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                Title="Column Variations" 
                DisableSelection="true"
                Width="600" 
                Height="350">
                <Store>
                    <ext:Store runat="server" >
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="booleanCol" Type="Boolean" />
                                    <ext:ModelField Name="dateCol" Type="Date" />
                                    <ext:ModelField Name="numberCol" Type="Int" />
                                    <ext:ModelField Name="AmountDue" Type="Float" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>                
                        <ext:RowNumbererColumn runat="server" Width="25" />
                        <ext:BooleanColumn runat="server" DataIndex="booleanCol" Text="Boolean"  />
                        <ext:CheckColumn runat="server" DataIndex="booleanCol" Text="Check" />
                        <ext:DateColumn runat="server" DataIndex="dateCol" Text="Date" />
                        <ext:Column ID="BarterDue" Text="Barter Due" DataIndex="AmountDue" Css="vertical-align:middle;text-align:right;"
                            MenuDisabled="true" Sortable="true" Width="100" runat="server" CustomSummaryType="renderAmountDue"
                            Align="Right">
                        </ext:Column>
                        <ext:NumberColumn runat="server" DataIndex="numberCol" Text="Number" Format="0.00" />
                        <ext:TemplateColumn runat="server" DataIndex="" MenuDisabled="true" Text="Template">
                            <Template runat="server">
                                <Html>
                                    <tpl for=".">
                                        {booleanCol}<br />
                                        {dateCol:date("d/m/Y")}<br />
                                        {numberCol}<br />
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:TemplateColumn>
                    </Columns>
                </ColumnModel>            
                <View>
                    <ext:GridView runat="server" StripeRows="false" />
                </View>
                <Features>
                <ext:Grouping runat="server" />
                <ext:Summary runat="server" />
                </Features>
                <Buttons>
                <ext:Button ID="btn" runat="server" Text="SetData">
                <DirectEvents>
                <Click OnEvent="SetData" />
                </DirectEvents>
                </ext:Button>
                <ext:Button ID="Button1" runat="server" Text="ReSetData">
                <DirectEvents>
                <Click OnEvent="ReSetData" />
                </DirectEvents>
                </ext:Button>
                </Buttons>
            </ext:GridPanel>  
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 25, 2014 at 3:09 PM. Reason: [CLOSED]
  2. #2
    Hi @iansriley,

    I guess the CustomSummaryType function is just not called for the hidden column. You might try to reshow the Column before applying the new data.

    Generally speaking, I sort of doubt that the entire approach is going to work well. I mean hiding/showing a column inside a function of calculating summary. I see you use a Grouping feature. What if you have a few groups? One group might need to have the Column shown, another - hidden.

    I would say it is kind of unsupported usage of summary function. A function is supposed to calculate the summary, nothing else. Though, you can try, maybe it will work OK for your requirement. I just let you know that it is on your own risks.
  3. #3
    Thank you for providing feedback.

    Actual requirement is, there is column "BarterDue", it should show when it is has amount >0 else hide and need to display sum of barter due based on some calculation. Few rows will have amount few not, so what i thought is based on sum(barterdue) i can show/hide the column, that is why i written show/hide logic in customsummarytype function.

    Please let me know how to do this type of requirement in ext.net.

    Thank you.
  4. #4
    I think you can try with your approach, just re-show the column binding new data.

Similar Threads

  1. Replies: 7
    Last Post: Jun 26, 2015, 11:39 AM
  2. Replies: 4
    Last Post: Jun 05, 2013, 10:09 AM
  3. Desktop Window gridpanel direct event not firing
    By Karun Javvadi in forum 2.x Help
    Replies: 0
    Last Post: Jul 31, 2012, 12:16 PM
  4. Replies: 4
    Last Post: Aug 16, 2010, 8:39 AM
  5. [CLOSED] [1.0] - GridPanel Column unable to Hide column
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 01, 2010, 5:37 PM

Tags for this Thread

Posting Permissions