How to capture click on Header Group Row

Page 2 of 2 FirstFirst 12
  1. #11
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
    
    <script type="text/javascript">
        Ext.net.GridPanel.prototype.doSelection = Ext.net.GridPanel.prototype.doSelection.createInterceptor(function () {
            this.getSelectionModel();
        });
    
        Ext.ux.grid.ColumnHeaderGroup.prototype.viewConfig.handleHdDown = function (e, t) {
            var el = Ext.get(t);
    
            if (el.hasClass('x-grid3-hd-btn')) {
                var hd, index, ms, cm;
    
                e.stopEvent();
                hd = this.findHeaderCell(t);
                Ext.fly(hd).addClass('x-grid3-hd-menu-open');
                index = this.getCellIndex(hd);
                this.hdCtxIndex = index;
                ms = this.hmenu.items;
                cm = this.cm;
                ms.get('asc').setDisabled(!cm.isSortable(index));
                ms.get('desc').setDisabled(!cm.isSortable(index));
    
                this.hmenu.on('hide', function () {
                    Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
                }, this, {
                    single: true
                });
                this.hmenu.show(t, 'tl-bl?');
            } else if (el.hasClass('ux-grid-hd-group-cell') || Ext.fly(t).up('.ux-grid-hd-group-cell')) {
                e.stopEvent();
    
                var hd, index, ms, cm;
    
                hd = this.findHeaderCell(t);
                index = this.getCellIndex(hd);
    
                alert(Ext.fly(hd).down(".x-grid3-hd-inner").dom.childNodes[1].data);
            }
        }
    
    </script>
    
    <script runat="server">
    
        [DirectMethod]
        public void Prepare_Click(object sender, DirectEventArgs e)
        {
            PrepareGrid(myGrid);
        }
    
        private void PrepareGrid(GridPanel grid)
        {
            var columns = new string[] { "Text1", "Num1", "Text2", "Num2", "Comments" };
    
            foreach (string col in columns)
            {
                Column newCol = new Column { Header = col, DataIndex = col, Width = 120, MenuDisabled = true, Sortable = false };
                grid.ColumnModel.Columns.Add(newCol);
            }
    
            var headerGroupRow = grid.View.View.HeaderGroupRows[0];
            var headerGroups = new[] { new { Header = "Group 1", Span = 2 }, new { Header = "Group 2", Span = 2 }, new { Header = "", Span = 1 } };
    
            foreach (var header in headerGroups)
            {
                headerGroupRow.Columns.Add(new HeaderGroupColumn
                {
                    Header = header.Header,
                    Align = Alignment.Center,
                    ColSpan = header.Span,
                });
            }
    
            grid.Controls.RemoveAt(0);
            grid.Render();
        }
    
        [DirectMethod]
        public void Load_Click(object sender, DirectEventArgs e)
        {
            DataTable data = new DataTable();
            data.Columns.Add("Date", typeof(DateTime));
            data.Columns.Add("Text1", typeof(string));
            data.Columns.Add("Num1", typeof(int));
            data.Columns.Add("Text2", typeof(string));
            data.Columns.Add("Num2", typeof(int));
            data.Columns.Add("Comments", typeof(string));
    
            data.Rows.Add(DateTime.Now, "Line 1", 10, "Some text", 20, "Correct");
            data.Rows.Add(DateTime.Now.AddDays(1).AddHours(1), "Line 2", 15, "More text", 25, "Wrong");
    
            this.strDemo.DataSource = data;
            this.strDemo.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 id="Head1" runat="server">
        <title>Dynamic Grid Column Header Click Problem</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <ext:Store ID="strDemo" runat="server">
                <Reader>
                    <ext:JsonReader IDProperty="Date">
                        <Fields>
                            <ext:RecordField Name="Date" Type="Date" />
                            <ext:RecordField Name="Text1" Type="String" />
                            <ext:RecordField Name="Num1" Type="Int" />
                            <ext:RecordField Name="Text2" Type="String" />
                            <ext:RecordField Name="Num2" Type="Int" />
                            <ext:RecordField Name="Comments" Type="String" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
    
            <ext:Viewport ID="Viewport1" runat="server" Layout="border">
                <Items>
    
                    <ext:Panel runat="server" Region="West" Width="100">
                        <Items>
                            <ext:Button runat="server" ID="btnPrepare" Text="Prepare Grid">
                                <DirectEvents>
                                    <Click OnEvent="Prepare_Click" />
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button runat="server" ID="btnLoad" Text="Load data">
                                <DirectEvents>
                                    <Click OnEvent="Load_Click" />
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Panel>
    
                    <ext:Panel runat="server" Region="Center">
                        <Items>
                            <ext:GridPanel ID="myGrid" runat="server" StoreID="strDemo" AutoHeight="true" EnableColumnMove="false" EnableColumnResize="false">
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:DateColumn Header="Day" DataIndex="Date" Format="MM/dd/yyyy" MenuDisabled="true" Sortable="false" />
                                        <ext:DateColumn Header="Time" DataIndex="Date" Format="HH:mm:ss" MenuDisabled="true" Sortable="false" />
                                    </Columns>
                                </ColumnModel>
                                <View>
                                    <ext:GroupingView>
                                        <HeaderGroupRows>
                                            <ext:HeaderGroupRow>
                                                <Columns>
                                                    <ext:HeaderGroupColumn Header="Date" ColSpan="2" Align="Center" />
                                                </Columns>
                                            </ext:HeaderGroupRow>
                                        </HeaderGroupRows>
                                    </ext:GroupingView>
                                </View>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
    
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Note that I replaced "textContent" (which was undefined) in the "handleHdDown" function with "data", which has the actual header text.

    Thanks a lot for all your time and effort on my problem.

    Andrew
    Last edited by ALobpreis; May 20, 2014 at 3:17 PM.
  2. #12
    Please clarify the steps to reproduce the problem and what the problem actually is. I cannot reproduce anything.
  3. #13
    1. Load the page.
    2. Click on "Date".
    3. A popup showing "Date" appears.
    4. Click on "Prepare Grid".
    5. New columns and group columns are rendered.
    6. Click on "Date", "Group 1" or "Group 2".
    7. Nothing happens.


    The exact file versions I am using are the same as before:
    Ext.Net.dll: 1.0.0.34580
    Ext.Net.Utilities.dll: 1.0.0.34577
    Newtonsoft.Json.dll: 3.5.0.0
    And this is the link I posted in the other thread, where I uploaded these files:
    https://dl.dropboxusercontent.com/u/336163/Ext.Net.rar

    By only replacing the dlls with those of version 1.2, the page starts working as expected.

    Thanks and regards,

    Andrew
  4. #14
    Quote Originally Posted by ALobpreis View Post
    6.Click on "Date", "Group 1" or "Group 2".
    7. Nothing happens.
    The message alert boxes appear for me. I tested with your dlls.

    That is strange. Does the problem appear in all the browser for you? I have tested in IE9, FireFox and Chrome.

    Also, please post the Page Sources and a DirectEvent's response after clicking the Prepare Grid Button. I will just compare with mine.
  5. #15
    I think I found the problem.

    I created a new test web site with version 1.0 and the same .aspx and it worked perfectly, so I thought the difference must be in the Web.config. I started comparing my project's with the default one and found out this:

    Our site:
      <system.web>
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceManager" validate="false"/>
    Default:
      <system.web>
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false"/>
    Our site:
      <system.webServer>
        <handlers>
          <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceManager"/>
    Default:
      <system.webServer>
        <handlers>
          <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler"/>
    If I switch ResouceManager <-> ResouceHandler, the new test web site starts having the issue I explained in my previous reply and my example in our project starts working correctly. So, my suspicions are confirmed.

    What's the difference between these two? Can I replace ResourceManager with ResourceHandler safely in our site?

    Thanks and regards,

    Andrew
    Last edited by ALobpreis; May 21, 2014 at 3:20 PM.
  6. #16
    I had a guess about a Web.config. You had to mention that.

    There must be Ext.Net.ResourceHandler there. I think it was a mistype in one our Web.config samples and this mistype has been spread to developers' Web.configs.
  7. #17
    That's good news I guess. The new web site was done installing Ext.Net 1.2.0 (that was the oldest version I managed to install with NuGet) and then I replaced the dlls, so the Webconfig I used actually belonged to 1.2. Is there a way to install 1.0 directly with NuGet?

    Our site is pretty big and this Webconfig change may impact hundreds of pages/popups. What's the exact difference between using one or another? What controls/behaviors are affected by this? How safe is do this modification?

    Thanks and regards,

    Andrew
  8. #18
    Quote Originally Posted by ALobpreis View Post
    Is there a way to install 1.0 directly with NuGet?
    No way, we started to release a NuGet package since v1.2.
    http://www.nuget.org/packages/Ext.NET/

    I think v1.2's Web.config is good enough for v1.0.

    Quote Originally Posted by ALobpreis View Post
    What's the exact difference between using one or another?
    Well, the difference is quite simple. Using Ext.Net.ResourceManager is wrong, using Ext.Net.ResourceHandler is correct:) By "wrong" I mean that our resources handler (ext.axd) is not attached at all and default WebResource.axd is being used.

    Quote Originally Posted by ALobpreis View Post
    What controls/behaviors are affected by this?
    It affects on loading any Ext.NET JavaScript, CSS resources.

    Quote Originally Posted by ALobpreis View Post
    How safe is do this modification?
    I would say it is safe for 99%.
  9. #19
    Up to now I haven't seen any problem with this change. What's more, as you said, now it's using ext.axd instead of WebResource.axd, as you pointed out I should be doing in this other topic.

    Thanks a lot for all your help, patience and dedication, Daniil. It was priceless. :)

    Andrew
  10. #20
    It was nice to deal with you.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [CLOSED] Gridpanel Header Group Width
    By CPA1158139 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 27, 2013, 11:59 AM
  2. Customizing Header Group Style
    By karthik.arian03 in forum 1.x Help
    Replies: 4
    Last Post: Apr 01, 2011, 3:09 PM
  3. Header Group in Grid Panel
    By Rakeshkumar.a in forum 1.x Help
    Replies: 1
    Last Post: Dec 21, 2010, 9:59 AM
  4. Replies: 1
    Last Post: Mar 02, 2010, 10:53 AM
  5. Capture GRID Group Click
    By Cr@iG in forum 1.x Help
    Replies: 0
    Last Post: Feb 19, 2010, 7:04 AM

Tags for this Thread

Posting Permissions