Button in the GridView Header not allowed

  1. #1

    Button in the GridView Header not allowed

    I m trying to call an AjaxMethod from a button which is in the HeaderRow of a GridView
    It gives me a Javascript error , even before clicking to it :"target is null or not an object"

    When I put a textfield in the HeaderRow as below it works fine
    Is this a bug or what?
    Thanks

    <%@ Page Language="C#" %>

    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Ext.IsAjaxRequest)
    {
    this.Store1.DataSource = new object[]
    {
    new object[] {"3m Co", 71.72, 0.02, 0.03, "9/1 12:00am"},
    new object[] {"Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am"},
    new object[] {"Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am"},
    };

    this.Store1.DataBind();
    }
    }
    [AjaxMethod]
    protected void btnSearch_Click(object sender, AjaxEventArgs e)
    {
    lblMock.Text += "search button clicked: ";
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title>Simple Array Grid - Coolite Toolkit Example</title>
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <h1>
    Array Grid Example</h1>
    <p>
    Demonstrates how to create a grid from Array data.</p>
    <ext:Label runat="server" ID="lblMock">
    </ext:Label>
    <ext:Store ID="Store1" runat="server">
    <Reader>
    <ext:ArrayReader>
    <Fields>
    <ext:RecordField Name="company" />
    <ext:RecordField Name="price" Type="Float" />
    </Fields>
    </ext:ArrayReader>
    </Reader>
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true"
    Title="Array Grid" TrackMouseOver="true" Width="600" Height="350">
    <ColumnModel ID="ColumnModel1" runat="server">
    <Columns>
    <ext:Column ColumnID="Company" Header="Company" Sortable="true" DataIndex="company" />
    <ext:Column Header="Price" Sortable="true" DataIndex="price" />
    </Columns>
    </ColumnModel>
    <View>
    <ext:GridView ID="GridView1" runat="server" SplitHandleWidth="10">
    <HeaderRows>
    <ext:HeaderRow>
    <Columns>
    <ext:HeaderColumn>
    <Component>
    <ext:TextField runat="server">
    <Listeners>
    <Focus Handler="alert('Hi');" />
    </Listeners>
    </ext:TextField>
    <%-- <ext:Button ID="TextField1" runat="server">
    <Listeners>
    <Click Handler="alert('Hi');" />
    </Listeners>
    </ext:Button>--%>
    </Component>
    </ext:HeaderColumn>
    <ext:HeaderColumn>
    <Component>
    <ext:Label runat="server" Text="None">
    </ext:Label>
    </Component>
    </ext:HeaderColumn>
    </Columns>
    </ext:HeaderRow>
    </HeaderRows>
    </ext:GridView>
    </View>
    <SelectionModel>
    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
    </SelectionModel>
    </ext:GridPanel>
    </form>
    </body>
    </html>

  2. #2

    RE: Button in the GridView Header not allowed

    Hi,

    Please set AutoWidthElement="false" for the HeaderColumn with button
  3. #3

    RE: Button in the GridView Header not allowed

    Thanks , it works great.

    Now my concern is that I m filling the GridPanel dynamically:
    The Button is in the HeaderRow in GridView . I want to call an Ajax Method from that button. But I m getting Ajax Error when I do that('Search failed', 'Error during ajax event!').
    It doesnt even let me go debug mode on click .


    The method works fine when I call it from a button anywhere else .


    Why would it give such an error when called from the button inside the Header ?
    And how can I see the Ajax Error or debug it ?

    <ext:HeaderColumn AutoWidthElement="false">
    <Component>
    <ext:Button ID="btnSearchInGrid1" Text="SearchButtonInGrid1" runat="server">
    <AjaxEvents>
    <Click OnEvent="btnSearch_Click2" Failure="Ext.MessageBox.alert('Search failed', 'Error during ajax event!');">
    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{GridPanel2}.body}" />
    </Click>
    </AjaxEvents>
    </ext:Button>
    </Component>
    </ext:HeaderColumn>





Similar Threads

  1. DirectEvent on Button - Content Not allowed?
    By Tbaseflug in forum 1.x Help
    Replies: 3
    Last Post: Jul 10, 2012, 8:29 PM
  2. [CLOSED] How to Hide Header row in gridview of GridPanel
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 06, 2012, 1:20 PM
  3. [CLOSED] gridView: set header row
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 30, 2010, 8:17 PM
  4. GridView Header Issue in IE 6.0
    By prasso in forum 1.x Help
    Replies: 0
    Last Post: Dec 17, 2009, 3:15 PM
  5. Why only one Toolbar allowed in GridView.BottomBar?
    By Jericho in forum Open Discussions
    Replies: 3
    Last Post: Apr 02, 2009, 12:51 PM

Posting Permissions