Back to index

PageInfo - Examples and Query Builder

All examples on this page use the javascript PageInfo from trimergo-pageinfo.js. For convenience, use this script to build queries for you own web projects.


Example - One criterion

let pageInfo = new PageInfo();
pageInfo.addCriterion(new Criterion('last_name', '=', 'Doe'));
pageInfo.addSorter(new Sorter("last_name", "asc"));

Example - Two criterions with AND

let pageInfo = new PageInfo();
let c1 = new Criterion('last_name', '=', 'Doe');
pageInfo.addCriterion(new Criterion('first_name', '=', 'John', c1));
pageInfo.addSorter(new Sorter("first_name", "desc"));

Example - Two criterions with OR

let pageInfo = new PageInfo();
pageInfo.addCriterion(new Criterion('last_name', '=', 'Doe'));
pageInfo.addCriterion(new Criterion('last_name', '=', 'Who'));

Example - Three criterions with AND & OR

let pageInfo = new PageInfo();
let c2 = new Criterion('last_name', '=', 'Who');
pageInfo.addCriterion(new Criterion('first_name', '=', 'Lisa', c2));
pageInfo.addCriterion(new Criterion('last_name', '=', 'Doe'));

Example - Search Needle in Haystack

let pageInfo = new PageInfo();
pageInfo.haystack.fields = ['last_name', 'first_name', 'address', 'city']
pageInfo.haystack.needle = 'John Doe';

Example - Combined

let pageInfo = new PageInfo();
pageInfo.pageNo = 2;
pageInfo.rpp = 50;
let c1 = new Criterion('last_name', '=', 'Doe');
let c2 = new Criterion('last_name', '=', 'Who');
let c3 = new Criterion('first_name', '=', 'Lisa', c2);
pageInfo.addCriterion(c1);
pageInfo.addCriterion(c3);
pageInfo.haystack.fields = ['last_name', 'first_name', 'address', 'city']
pageInfo.haystack.needle = 'John Doe';
pageInfo.addSorter(new Sorter("last_name", "asc"));
pageInfo.addSorter(new Sorter("first_name", "desc"));

Query Builder

Query Builder
WHERE
OR
OR
OR
ORDER BY