Grid
Grid Client Settings
DRevealGridClientSettings is a configuration class designed to help users customize the behavior of dReveal Grids in test automation or integration scenarios. This configuration is used to define how data is queried, filtered, displayed, and exported.
This class encapsulates all required settings to retrieve and display data from a .dRepX report file using a database connection. It supports features such as filtering, paging, column visibility, and user-defined parameters.
Properties
| Name | Type | Description |
|---|---|---|
| ConnectionString | string | Specifies the database connection string used to query data. Default value: null |
| File | MemoryStream | The dReveal report file .dRepX in memory stream format. Required for data extraction. Default value: null |
| FileName | string | Name of the dReveal report file. This property is mandatory. Default value: null |
| PageLength | int | Number of rows to return per page when paginating the data. Default value: 0 |
| PageIndex | int | Index of the current page to retrieve data for. Starts at 0. Default value: 0 |
| StrictMode | bool | This property allows the execution of a Grid regardless its design when set as false, when the value is set in true and the report has required filters, no Grid execution is able without adding that information through the client settings. Default value: false |
| VisibleColumns | ICollection<DRevealGridColumn> | List of column names to display in the resulting data. If null, the default columns defined in the report designer are used. Default value: null |
| Filters | ICollection<IFilter> | Collection of filter objects to apply to the data, allowing dynamic filtering in the grid. Default value: null |
| UserDefinedParameters | ICollection<DRevealParameter> | List of user-defined parameters used to modify the data query in the grid. Default value: null |
| HtmlColumnExportedMode | bool | Determines if HTML columns are exported as plain text false or with HTML formatting preserved true. Default value: false |
| ExportedMode | bool | If true, exports the full dataset, ignoring PageLength and PageIndex. Default value: false |
| DisplaySummaries | DisplaySummary | Defines how summary data is displayed in the grid (e.g., Total, Group). Default value: InfoArch.Common.Core.Structures.Model.DisplaySummary |
| ExpandAllRows | bool | Specifies whether all rows in the grid should be expanded by default. Default value: true |
| ExportingFolderPath | string | Directory path where exported files will be saved. Default value: empty |
| ExportFileName | string | Name of the exported file. Default value: empty |
| IsSaveStateAction | bool | If true, enables the system to save the current grid state for future sessions. Default value: false |
| UserCustomization | string | Stores user preferences and grid layout settings. Default value: null |
| DrillThroughParameters | string | An encrypted string containing parameters for Drill-Through actions. Default value: null |
| IncludeAnchorColumns | bool | If true, includes special anchor columns in the display. Default is false. Default value: false |
Methods
GetDRevealGridResult
Gets the dReveal grid result by applying the provided client settings. It receives a DRevealGridClientSettings object and retrieves a DRevealGridResult object with the final result containing visible columns, data and loading time.
Definition
public static DRevealGridResult GetDRevealGridResult(DRevealGridClientSettings gridClientSettings);
Usage Example
[TestMethod]
public void GetDRevealGridResult()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
string fileName = "Product Inventory.dRepX"; //Replace this variable with your grid report name.
string sharedFolderPath = ConfigurationManager.AppSettings["SharedFolderPath"];
string filePath = $"{sharedFolderPath}\\{fileName}";
DRevealGridClientSettings dRevealGridClientSettings = new DRevealGridClientSettings()
{
ConnectionString = connectionString,
File = GetStream(filePath),
FileName = fileName,
PageLength = 20,
};
DRevealGridResult dRevealGridResult = InfoArch.Common.DataExtraction.Helper.DRevealGridHelper.GetDRevealGridResult(dRevealGridClientSettings);
Assert.IsNotNull(dRevealGridResult, "The DRevealGridResult should not be null.");
}
ExportToExcelXL
Exports the grid data to an Excel XL file format using the provided DRevealGridClientSettings client settings.
Definition
public static void ExportToExcelXL(DRevealGridClientSettings gridClientSettings)
Usage Example
[TestMethod]
public void ExportGridToExcelXL()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
string fileName = "Product Inventory.dRepX"; //Replace this variable with your grid report name.
string sharedFolderPath = ConfigurationManager.AppSettings["SharedFolderPath"];
string filePath = $"{sharedFolderPath}\\{fileName}";
DRevealGridClientSettings dRevealGridClientSettings = new DRevealGridClientSettings()
{
ConnectionString = connectionString,
File = GetStream(filePath),
FileName = fileName,
ExportedMode = true,
ExportFileName = "ExportedGridData",
Filters = new List<IFilter>(),
ExportingFolderPath = sharedFolderPath,
};
InfoArch.Common.DataExtraction.Helper.DRevealGridHelper.ExportToExcelXL(dRevealGridClientSettings);
string exportedFilePath = dRevealGridClientSettings.ExportingFolderPath + "\\" + dRevealGridClientSettings.ExportFileName + ".xlsx";
Assert.IsTrue(File.Exists(exportedFilePath), "The exported Excel file should exist.");
File.Delete(exportedFilePath);
}
GetMetadata
Retrieves a DRevealGridMetadata object with the metadata of the grid, including columns and filters, using the specified DRevealGridClientSettings client settings.
Definition
public static DRevealGridMetadata GetMetadata(DRevealGridClientSettings gridClientSettings)
Usage Example
[TestMethod]
public void GetGridMetadata()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
string fileName = "Product Inventory.dRepX"; //Replace this variable with your grid report name.
string sharedFolderPath = ConfigurationManager.AppSettings["SharedFolderPath"];
string filePath = $"{sharedFolderPath}\\{fileName}";
DRevealGridClientSettings dRevealGridClientSettings = new DRevealGridClientSettings()
{
ConnectionString = connectionString,
File = GetStream(filePath),
FileName = fileName,
};
DRevealGridMetadata gridMetadata = InfoArch.Common.DataExtraction.Helper.DRevealGridHelper.GetMetadata(dRevealGridClientSettings);
Assert.IsNotNull(gridMetadata, "The DRevealGridMetadata should not be null.");
}
GetMetadata (Overload)
Retrieves a DRevealGridMetadata object with the metadata of the grid, including columns and filters, using the following parameters:
Definition
public static DRevealGridMetadata GetMetadata(MemoryStream modelStream, string connectionString, ICollection<Parameter.DRevealParameter> parameters)
Usage Example
//Method to add a user defined parameter "Culture" to the dRevealGridClientSettings
private List<DRevealParameter> GetUserDefinedCultureParameter()
{
return new List<DRevealParameter>()
{
new DRevealParameter() { Name = "Culture", Value = Thread.CurrentThread.CurrentUICulture.Name, DataType = DataType.String }
};
}
[TestMethod]
public void GetGridMetaDataOverloaded()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
string fileName = "Product Inventory.dRepX"; //Replace this variable with your grid report name.
string sharedFolderPath = ConfigurationManager.AppSettings["SharedFolderPath"];
string filePath = $"{sharedFolderPath}\\{fileName}";
DRevealGridClientSettings dRevealGridClientSettings = new DRevealGridClientSettings()
{
ConnectionString = connectionString,
FileName = fileName,
File = GetStream(filePath),
UserDefinedParameters = GetUserDefinedCultureParameter(),
};
dRevealGridClientSettings.UserDefinedParameters.First(x => x.Name == "Culture").Value = "zh-CN";
DRevealGridMetadata gridMetadata = InfoArch.Common.DataExtraction.Helper.DRevealGridHelper.GetMetadata(dRevealGridClientSettings.File, dRevealGridClientSettings.ConnectionString, dRevealGridClientSettings.UserDefinedParameters);
Assert.IsNotNull(gridMetadata, "The DRevealGridMetadata should not be null.");
}
ConvertQueryStringCollectionToString
Converts a collection of query string parameters into a securely encrypted and encoded string, using a QueryStringCollection object of query string key-value pairs and returns an encrypted and encoded string suitable for secure transmission as string.
Definition
public static string ConvertQueryStringCollectionToString(QueryStringCollection queryStrings)
Usage Example
QueryStringCollection queryStringCollection = new QueryStringCollection();
queryStringCollection.Add(new QueryString("columnKey", "columnName", "columnKeyValue"));
Replace the "columnName" and "columnKeyValue" with the correct values from the DataBase used (AdventureWorksDW2022) as is shown in following:
QueryStringCollection queryStringCollection = new QueryStringCollection();
queryStringCollection.Add(new QueryString("columnKey", "MonthName", "August")); //Values from "Product Inventory.dRepX" grid report.
string drillThroughGridParameters = DRevealGridHelper.ConvertQueryStringCollectionToString(queryStringCollection);
EncryptDrillThroughParameters
Encrypts a DataDrillThrough data structure to a secure string format for safe transmission between reports.
Definition
public static string EncryptDrillThroughParameters(DataDrillThrough dataDrillThrough)
Usage Example
DataDrillThrough drillThrough = new DataDrillThrough();
drillThrough.EncryptedQueryString = drillThroughGridParameters; //drillThroughGridParameters variable set in ConvertQueryStringCollectionToString usage example.
drillThrough.Filters = DRevealGridHelper.GetFilters(defaultGridSettings);
string encodedParameters = DRevealGridHelper.EncryptDrillThroughParameters(drillThrough);
GetFilters
Method that obtains the Filters from DReveal grid using the DRevealGridClientSettings.
Definition
public static DataSourceFilters GetFilters(DRevealGridClientSettings gridClientSettings)
Filter Configuration Usage Example
Create a GetGridFilterToAdd helper method in order to get the filter as IFilter:
Libraries needed for the method:
using InfoArch.Common.DataExtraction.Helper;
using InfoArch.Common.Core.Structures.Filters;
using System.Linq;
using System;
Helper method:
private IFilter GetGridFilterToAdd(string filterName, string filterValueToFind, DRevealGridClientSettings gridClientSettings)
{
var availableFilterValueList = FilterHelper.GetFilterValuesFromGrid(filterName, gridClientSettings);
var filterValue = availableFilterValueList.FirstOrDefault(filter => filter.Label.Equals(filterValueToFind, StringComparison.OrdinalIgnoreCase));
return FilterHelper.GetFilter(filterName, filterValue);
}
Then the user can use the GetGridFilterToAdd method in order to add filters in the client settings as follow:
[TestMethod]
public void GetDRevealGridResultWithFilter()
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
string fileName = "Product Inventory.dRepX"; //Replace this variable with your grid report name.
string sharedFolderPath = ConfigurationManager.AppSettings["SharedFolderPath"];
string filePath = $"{sharedFolderPath}\\{fileName}";
DRevealGridClientSettings dRevealGridClientSettings = new DRevealGridClientSettings()
{
ConnectionString = connectionString,
File = GetStream(filePath),
FileName = fileName,
PageLength = 20,
};
string filterName = "Category"; //filterName value is obtained from the grid designer in the Filtering Option form.
string filterValueToFind = "Clothing"; //filterValueToFind value is obtained from DataBase.
IFilter filterToAdd = GetGridFilterToAdd(filterName, filterValueToFind, dRevealGridClientSettings);
dRevealGridClientSettings.Filters = new List<IFilter>() { filterToAdd };
DRevealGridResult dRevealGridResult = InfoArch.Common.DataExtraction.Helper.DRevealGridHelper.GetDRevealGridResult(dRevealGridClientSettings);
Assert.IsNotNull(dRevealGridResult, "The DRevealGridResult should not be null.");
}