Dashboard pages
A dashboard is a page of widgets — KPI tiles, charts, mini-tables, activity feeds. Most are data-bound in the Designer (no code), but you can also script them for live values, refreshes and drill-downs. Each recipe says exactly where the code goes.
Bind first, script second. Select a Stat Card, KPI, Chart,
Mini-Table or Recent Activity widget in the Designer and pick a table + column +
aggregate in its Properties — it fills itself from the database. Reach for code only when you need
something the binding can't express.
Ways to add data to a dashboard
| Want… | Do this |
|---|---|
| A number, chart or table from one query | Designer → drop a KPI / Chart / Mini-Table widget → set table + aggregate. |
| A custom / cross-table figure | A server action + a Custom Button or On-Page-Init fetch (below). |
| Live values that refresh | On Page Init (JS) + pp.run() on a timer. |
| Click a tile to open a filtered list | A Custom Button, or the Chart's built-in drill-down (Designer). |
Recipes
1 · A custom figure from a named server action
WhereCustom Functions → PHP → function action_openTickets($params)PHP
function action_openTickets($params) {
return (int) dbValue("SELECT COUNT(*) FROM tickets WHERE status = 'open'");
}
WhereMenu / Dashboard → Client Events → On Page InitJS
var n = await pp.run('openTickets', {});
Runner.getControl('open_tickets').setValue(n); // a Stat Card / field bound by name
2 · Refresh a KPI every 30 seconds
WhereMenu / Dashboard → Client Events → On Page InitJS
async function tick() {
var n = await pp.run('openTickets', {});
Runner.getControl('open_tickets').setValue(n);
}
tick();
setInterval(tick, 30000);
3 · A "Refresh now" Custom Button
WhereDesigner → Custom Button → Client AfterJS
Runner.reloadGrid(); // or location.reload() to refresh every widget
4 · Greet the signed-in user
WhereGlobal Events → Application → Before DisplayPHP
pp_set_proxy('welcome', 'Welcome back, ' . \PpPhp\Core\Security::CurrentUsername());
WhereMenu / Dashboard → Client Events → On Page InitJS
var msg = pp.getProxy('welcome', '');
if (msg) pp.dialog.toast('info', msg);
5 · A KPI that colours itself on a threshold
WhereMenu / Dashboard → Client Events → On Page InitJS
var overdue = +Runner.getControl('overdue').getValue() || 0;
if (overdue > 0) Runner.getControl('overdue').addStyle('color:#dc2626;font-weight:800');
6 · Build a whole panel from a server action
WhereMenu / Dashboard → Client Events → On Page InitJS
var rows = await pp.run('topProducts', { limit: 5 }); // returns [{name, sold}, …]
document.getElementById('topProducts').innerHTML =
rows.map(function (r) { return '<li>' + pp.util.escapeHtml(r.name) + ' — ' + r.sold + '</li>'; }).join('');