This method allows the user to filter and order records in a panel.
This method has no arguments.
This method is executed in a number of steps:
To get the theme panel of this page then:
const Theme = this.theme;
a. Collect the filter and sorting inputs by
getting the condition entered by the user and convert it into a valid SQL statement.
const condition = (<HTMLInputElement>this.get_element('filter')).value;
getting the sorting clause from the user.
const clause = (<HTMLInputElement> this.get_element("sort")).value;
b. Completing the where and sorting clauses using the below,
const where = condition === ""?"":'where ${condition}';
Then get the entity's name.
const ename = this.subject[0];
afterwards compile the complete clause where sorting by default is ascending with the primary keys otherwise the user overrides the default value.
xxxxxxxxxx
const sort = clause === ""
?` order by ${ename}.${ename} Asc`
:` order by ${clause}`;
c. Use the original SQL statement to formulate a new working SQL in assumption that it has no where and ordering clause.
xxxxxxxxxx
let sql;
if (Theme.original_sql === null){
sql = Theme.sql;
Theme.original_sql = Theme.sql!;
}
else{
sql = Theme.original_sql;
}
Update the current SQL adding the where and sorting clauses
xxxxxxxxxx
Theme.sql = `${sql} ${where} ${sort} `;
d. Repaint the theme panel with the following.
update the maximum records getting the number of records as a table of type (Ifuel).
xxxxxxxxxx
const count = await server.exec(
"database",
[Theme.dbase!.name],
"get_sql_data",
[`select count(*) as max_record from (${Theme.sql}) as x`]
);
set the maximum number of records.
xxxxxxxxxx
Theme.max_records = <number>count[0]["max_record"];
clear the table body
xxxxxxxxxx
this.document.querySelector('tbody')!.innerHTML = "";
reset the view
xxxxxxxxxx
Theme.view.top = 0;
Theme.view.bottom = 0;
and finally go to the first record.
xxxxxxxxxx
Theme.goto(0);