inserting virtual table

166 views
Skip to first unread message

Александр Рюмин

unread,
Sep 25, 2020, 2:27:04 PM9/25/20
to Jam.py Users Mailing List
Hi
Came to virtual tables. Created a virtual table with fields. Now you need to fill in the form of this table when you open the form through 'select * from tab1 union select * from tab2'
is that possible?

Drazen D. Babic

unread,
Sep 25, 2020, 10:38:04 PM9/25/20
to Jam.py Users Mailing List
Hello,
please describe what would you like to achieve, since there might be a better ways for doing it.
Thanks


Andrew Yushev

unread,
Oct 8, 2020, 7:15:01 AM10/8/20
to Drazen D. Babic, Jam.py Users Mailing List
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
        }
    ]




сб, 26 сент. 2020 г. в 05:38, Drazen D. Babic <bab...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/9ef4125a-697d-4fc4-bfbf-0ae416784c4an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages