ASPxClientGridView.GetColumnLayout Method
Returns an object specifying the grid column’s layout.
Declaration
GetColumnLayout(): any
Returns
Type | Description |
---|---|
any | An object specifying the grid column’s layout. |
Remarks
To set the grid column’s layout, use the ASPxClientGridView.SetColumnLayout method.
Note
The GetColumnLayout method works only if the ASPxGridViewBehaviorSettings.ProcessColumnMoveOnClient property is set to true
.
Example
The following example illustrates how to get and restore a column’s state on the client side.
The ASPxClientGridView.GetColumnLayout
is used to get a column’s state.
var initialColumnLayout = null;
function Grid_Init(s, e) {
initialColumnLayout = s.GetColumnLayout();
}
It returns an object that provides the following fields:
column
field - Provides all the column’s information.visibleIndex
field - Provides the column’s visible index.parentColumn
field - Provides the parent column’s information. This field is null if you don’t use the banded columns.
{ “column”: ASPxClientGridViewColumn, “visibleIndex”: -1, “parentColumn”: ASPxClientGridViewColumn },
To restore the layout, use the client-side ASPxClientGridView.SetColumnLayout method and pass the previously obtained or customized layout.
function RestoreColumnLayout() {
grid.SetColumnLayout(initialColumnLayout);
}
Result code:
function click() {
RestoreColumnLayout();
}
var initialColumnLayout = null;
function Grid_Init(s, e) {
initialColumnLayout = s.GetColumnLayout();
}
function RestoreColumnLayout() {
grid.SetColumnLayout(initialColumnLayout);
}
<dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="grid"
AutoGenerateColumns="False" DataSourceID="AccessDataSource1" KeyFieldName="ProductID">
<Columns>
<dx:GridViewCommandColumn ShowEditButton="True" VisibleIndex="7" />
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2" />
<dx:GridViewDataTextColumn FieldName="SupplierID" VisibleIndex="3" />
<%-- ... --%>
</Columns>
<SettingsBehavior ProcessColumnMoveOnClient="true" ColumnMoveMode="ThroughHierarchy" />
<ClientSideEvents Init="Grid_Init" />
</dx:ASPxGridView>
See Also