🎯 Super simple app with server code as a first step in understanding Jam

17 views
Skip to first unread message

Dean Babic

unread,
Apr 8, 2026, 1:52:33 AM (8 days ago) Apr 8
to Jam.py Users Mailing List
Home is a Virtual table with nothing in it but a JS code and a template:
<!-- Home page start -->
<div class="home-view">
<div class="form-body">
<div class="row">
<div class="date"></div>
<div id="date"></div>
</div>
</div>
</div>


function on_view_form_created(item) {
var date = new Date(new Date().setMonth(new Date().getMonth() - 48));
$("#date").text(date);
}

It displays:
Screenshot from 2026-04-08 13-38-06.png


Now that we know how to "bind" the value to some DIV ID (date), we can calculate summary for some table. For example "test" table with f1 field and display it:

Screenshot from 2026-04-08 13-36-29.png
Here is a JS code:
function on_view_form_created(item) {
var total;
item.server("get_total", function (total, error) {
if (error) {
console.error("Error fetching total:", error);
return;
}
$("#date").text(total);
});
}

and the server:
def get_total(item):
result = 0;
copy = task.test.copy()
item.set_where(deleted=0)

copy.open(fields=['f1'],
funcs={'f1': 'sum'})

if copy.record_count():
result = copy.f1.value
return result; Thats it. D.
Reply all
Reply to author
Forward
0 new messages