Skip to main content

ASPxClientGridView.CustomizationWindowCloseUp Event

Fires after the Customization Window has been closed.

Declaration

CustomizationWindowCloseUp: ASPxClientEvent<ASPxClientEventHandler<ASPxClientGridView>>

Event Data

The CustomizationWindowCloseUp event's data class is ASPxClientEventArgs.

Example

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.

<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>

<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>

<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" />
    <SettingsBehavior EnableCustomizationWindow="true" />
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" >
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ProductName" />
        <dx:GridViewDataTextColumn FieldName="SupplierID" />
        <dx:GridViewDataTextColumn FieldName="CategoryID" />
    </Columns>
</dx:ASPxGridView>

<dx:ASPxHiddenField ID="hf" ClientInstanceName="hiddenField" runat="server">
</dx:ASPxHiddenField>
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    ASPxGridView gridView = (ASPxGridView)sender;
    foreach (GridViewColumn column in gridView.Columns) {
        if (Convert.ToBoolean(hf["columnsInWindow"])) {
            if (column.Visible && column.ShowInCustomizationForm)
                column.Visible = false;
        } else {
            if (!column.Visible && column.ShowInCustomizationForm)
                column.Visible = true;
        }
    }
}
protected void grid_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e) {
    if (e.CallbackName == "COLUMNMOVE") {
        ASPxGridView gridView = (ASPxGridView)sender;
        gridView.JSProperties["cpColumnsInHeader"] = false;
        foreach (GridViewColumn column in gridView.Columns) {
            if (column.Visible && column.ShowInCustomizationForm) {
                gridView.JSProperties["cpColumnsInHeader"] = true;
                break;
            }
        }
    }
}
See Also