Moving record up and down in table - view

35 views
Skip to first unread message

Danijel Kaurin

unread,
Aug 4, 2022, 3:57:07 AM8/4/22
to Jam.py Users Mailing List
Hi Andrew.

I want for example to implement buttons up and down to move customers order_id i customers - view form. This is based on this form logic:

button_up_down.PNG

I looked in jam.js code but didn't succed to write working code. Can you practicaly explain how to do to that?

Regards

Danijel Kaurin

Andrew Yushev

unread,
Aug 6, 2022, 2:46:27 AM8/6/22
to Danijel Kaurin, Jam.py Users Mailing List
Hi, Danijel

I am sorry for the late reply.

I use the following code. The _dataset is an array of records. It is undocumented.
 
function move_vert(item, rec1, rec2) {
    let r1 = item._dataset[rec1],
        r2 = item._dataset[rec2],
        i,
        t;
    for (i = 0; i < r1.length - 1; i++) {
        t = r1[i];
        r1[i] = r2[i];
        r2[i] = t;
    }
    item.update_controls();
    item.rec_no = rec2;
}

function move_record_up(item) {
    if (item.rec_no > 0) {
        move_vert(item, item.rec_no, item.rec_no - 1);
    }
}

function move_record_down(item) {
    if (item.rec_no < item.rec_count - 1) {
        move_vert(item, item.rec_no, item.rec_no + 1);
    }
}

Regards,
Andrew

чт, 4 авг. 2022 г. в 10:57, Danijel Kaurin <yonika...@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/2446493d-6aa5-43b0-92da-871f3e92eae6n%40googlegroups.com.

Danijel Kaurin

unread,
Aug 6, 2022, 2:41:05 PM8/6/22
to Jam.py Users Mailing List
Thank you Andrew.

On first, it works, now need to implement that on order_id db field.

Regards

Danijel Kaurin

Reply all
Reply to author
Forward
0 new messages