Hi,
The usual way to fill the virtual table is to use the on_after_open event handler
The view method opens the item and for virtual tables it opens them empty.
For example, the following code sets paginate attribute of the item to false
and then fills it with records that it gets on the server using get_records function
The client side code:
function on_view_form_created(item) {
item.paginate = false;
}
function on_after_open(item) {
item.server('get_records', function(records) {
records.forEach(function(rec) {
item.append();
item.product.value = rec.product;
item.price.value = rec.price;
item.post();
});
});
}
the server side code:
def get_records(item):
return [
{
'product': 'Product1',
'price': 10
},
{
'product': 'Product2',
'price': 20
}
]