Datagrid Utilities
The Clarity datagrid in Datagrid Utilities is designed to emit a state whenever a user interacts with pagination buttons, filters, or sorting options. To facilitate seamless integration with API requests, the Clarity datagrid state requires conversion into an object suitable for HttpParams. To streamline this process, we offer the convertToHttpParams function.
The output of the convertToHttpParams function is a structured data model, ensuring compatibility with HttpParams for subsequent API requests. This model enhances the efficiency of data transmission and retrieval. Below is an overview of the data model returned by the convertToHttpParams function.
export interface PageQuery {
/**
* The page number for pagination. Starts from 1.
*/
page: number;
/**
* The number of items per page in the result set.
*/
pageSize: number;
/**
* Optional: The field to sort in ascending order.
*/
sortAsc?: string;
/**
* Optional: The field to sort in descending order.
*/
sortDesc?: string;
/**
* Optional: The filter criteria in FIQL (Feed Item Query Language) format.
* Example: name==*term*;enabled==false
*/
filter?: string;
}Utilizing this function simplifies the conversion process, transforming the Clarity datagrid state presented in the below first block into the corresponding code in the second block effortlessly.
// Clarity Datagrid state example
{
"page": {"from": 0, "to": 9, "size": 10, "current": 1},
"sort": {"by": "date", "reverse": false},
"filters": [
{"property": "name", "value": "mike"},
{"property": "job", "value": "programming"}
]
}// output data returned by convertToHttpParams
{
"page": 1,
"pageSize": 10,
"filter": "name==*mike*;job==*programming*",
"sortAsc": "date"
}