Current filter:
                                You should refresh the page.
                                Support Center

                                ASPxGridView - How to move all columns from Header to Customization Window at once

                                0

                                The example demonstrates how to move all columns from Header to Customization Window (and reverse) at once by clicking the external button. The button's state is synchronized automatically based on the state of the ASPxGridView's Columns.

                                See Also:
                                ASPxGridView - How to trace the process of dragging columns to Customization Window and within a Header

                                You must  log in  or  register  to leave comments
                                Select file
                                • Default.aspx
                                • Default.aspx.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2013 vol 1.4 - v2013 vol 2.9
                                • v2010 vol 2.6 - v2012 vol 2.16
                                <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
                                <%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
                                <%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
                                <%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>
                                <!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">
                                
                                    <script type="text/javascript">
                                        function OnCustomizationWindowCloseUp(s, e) {
                                            btnMoveColumns.SetEnabled(false);
                                            UpdateBtnToggleCustomWindowText();
                                        }
                                        function OnBtnToggleCustomWindowClick(s, e) {
                                            btnMoveColumns.SetEnabled(!grid.IsCustomizationWindowVisible());
                                            if (grid.IsCustomizationWindowVisible())
                                                grid.HideCustomizationWindow();
                                            else
                                                grid.ShowCustomizationWindow();
                                            UpdateBtnToggleCustomWindowText();
                                        }
                                        function OnBtnMoveColumnsClick(s, e) {
                                            if (!hiddenField.Get('columnsInWindow')) {
                                                hiddenField.Set('columnsInWindow', true);
                                            }
                                            else {
                                                hiddenField.Set('columnsInWindow', false);
                                            }
                                            UpdateBtnMoveColumnsText(hiddenField.Get('columnsInWindow'));
                                            grid.PerformCallback();
                                        }
                                        function UpdateBtnToggleCustomWindowText() {
                                            var text = grid.IsCustomizationWindowVisible() ? 'Hide' : 'Show';
                                            text += ' Customization Window';
                                            btnToggleCustomWindow.SetText(text);
                                        }
                                        function UpdateBtnMoveColumnsText(moveToWindow) {
                                            var text = 'Move all columns to ';
                                            text += moveToWindow ? 'Header' : 'Customization Window';
                                            btnMoveColumns.SetText(text);
                                        }
                                        function OnEndCallBack(s, e) {
                                            if (s.cpColumnsInHeader != undefined) {
                                                UpdateBtnMoveColumnsText(!s.cpColumnsInHeader);
                                                hiddenField.Set('columnsInWindow', !s.cpColumnsInHeader);
                                                delete s.cpColumnsInHeader;
                                            }
                                        } 
                                               
                                    </script>
                                
                                    <title></title>
                                </head>
                                <body>
                                    <form id="form1" runat="server">
                                    <div>
                                        <table>
                                            <tr>
                                                <td>
                                                    <dx:ASPxButton ID="buttonToggleCustomWindow" runat="server" ClientInstanceName="btnToggleCustomWindow"
                                                        Text="Show Customization Window" AutoPostBack="false" Width="250px">
                                                        <ClientSideEvents Click="OnBtnToggleCustomWindowClick" />
                                                    </dx:ASPxButton>
                                                </td>
                                                <td>
                                                    <dx:ASPxButton ID="buttonMoveColumns" runat="server" ClientInstanceName="btnMoveColumns"
                                                        Text="Move all columns to Customization Window" ClientEnabled="false" AutoPostBack="false">
                                                        <ClientSideEvents Click="OnBtnMoveColumnsClick" />
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
                                        <dx:ASPxGridView ID="grid" runat="server" ClientInstanceName="grid" AutoGenerateColumns="False"
                                            DataSourceID="gridDataSource" KeyFieldName="ProductID" OnCustomCallback="grid_CustomCallback"
                                            OnAfterPerformCallback="grid_AfterPerformCallback">
                                            <ClientSideEvents EndCallback="OnEndCallBack" CustomizationWindowCloseUp="OnCustomizationWindowCloseUp" />
                                            <SettingsCustomizationWindow Enabled="True" />
                                            <Columns>
                                                <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
                                                    <EditFormSettings Visible="False" />
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="SupplierID" VisibleIndex="2">
                                                </dx:GridViewDataTextColumn>
                                                <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="3">
                                                </dx:GridViewDataTextColumn>
                                            </Columns>
                                        </dx:ASPxGridView>
                                        <asp:AccessDataSource ID="gridDataSource" runat="server" DataFile="~/App_Data/nwind.mdb"
                                            SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID] FROM [Products]">
                                        </asp:AccessDataSource>
                                    </div>
                                    <dx:ASPxHiddenField ID="hf" ClientInstanceName="hiddenField" runat="server">
                                    </dx:ASPxHiddenField>
                                    </form>
                                </body>
                                </html>

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners