Layout

  • 2 min to read

ASPxCardView allows you to save information on its layout (filter and paging) to a database and then restore it. To specify what information on the ASPxCardView layout is saved, use options provided by the ASPxCardView.SettingsCookies property.

Automatic Layout Saving/Restoring

The ASPxCardView ASPxGridBase.ClientLayout event enables you to save the grid's layout each time it is being changed and restore it on first page load. This event provides the ASPxClientLayoutArgs.LayoutMode property that indicates whether the grid's layout should be saved or restored.

This example shows how to save or restore the ASPxCardView layout to or from a data store.

protected void CardView_ClientLayout(object sender, ASPxClientLayoutArgs e)
{
    if (e.LayoutMode == DevExpress.Web.ClientLayoutMode.Saving)
    {
        SaveUserLayoutToDatabase(userID, "Account", e.LayoutData);
    }
    else
    {
        if (System.IO.File.Exists(fileName))
            e.LayoutData = RestoreUserLayoutFromDatabase(userID, "Account");
    }
}

Manual Layout Saving/Restoring

ASPxCardView provides two methods that enable you to manually save and restore its layout. They are:

This example shows how to manually save and restore the previously saved layout. When the Save Layout or Load Layout button is clicked, the grid's ASPxClientCardView.PerformCallback client method is used to send a callback to the server. This generates the server-side ASPxCardView.CustomCallback event, which is handled to save or restore the grid's layout.

protected void ASPxCardView1_CustomCallback(object sender, ASPxCardViewCustomCallbackEventArgs e)
{
if (e.Parameters == "save") {
    SaveUserLayoutToDatabase("userID", "Layout", ASPxCardView1.SaveClientLayout());
}
if (e.Parameters == "load") {
    ASPxCardView1.LoadClientLayout(GetUserLayoutFromDatabase("userID", "Layout"));
}