Hide and Show filter in the Filter Forms

62 views
Skip to first unread message

Ari Sobel

unread,
Aug 15, 2023, 8:56:05 AM8/15/23
to Jam.py Users Mailing List
Hi to all!

Is there a way to Hide and Show filter in the Filter Forms programmatically?

Like this rounded below:

image.png

Danijel Kaurin

unread,
Aug 15, 2023, 2:03:18 PM8/15/23
to Ari Sobel, Jam.py Users Mailing List
Hi Ari.

You have on_param_form_created event and also on_param_form_changed. Use them to handle show and hide funcs.

Regards

--
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/CAD2XFNe%2BD%3DM_ZBXXqOtCGae7ndSpEiXU1Y4m_3OMtrY6WdL6sA%40mail.gmail.com.

Andrew Yushev

unread,
Aug 16, 2023, 12:36:00 PM8/16/23
to Danijel Kaurin, Ari Sobel, Jam.py Users Mailing List
Hi

Danijel is right, but you must change the word param with filter.


вт, 15 авг. 2023 г. в 21:03, Danijel Kaurin <yonika...@gmail.com>:

Andrew Yushev

unread,
Aug 16, 2023, 12:50:55 PM8/16/23
to Danijel Kaurin, Ari Sobel, Jam.py Users Mailing List
I tried to hide a filter and found a problem.

To hide a filter you need first to change the on_filter_form_created event handler in the task client module.

function on_filter_form_created(item) {
    item.filter_options.title = item.item_caption + ' - filters';
    item.filter_form.find("#cancel-btn").on('click.task', function() {
        item.close_filter_form();
    });
    item.filter_form.find("#ok-btn").on('click.task', function() {
        item.set_order_by(item.view_options.default_order);
        item.apply_filters(item._search_params);
    });
    if (!item.master && item.owner.on_filter_form_created) {
        item.owner.on_filter_form_created(item);
    }
    if (item.on_filter_form_created) {
        item.on_filter_form_created(item);
    }
    item.create_filter_inputs(item.filter_form.find(".edit-body"));    
    return true;
}

After this change the following code in the invoices client module of the demo app will work and hide the customer filter.

function on_filter_form_created(item) {
    item.filters.customer.visible = false;
}

ср, 16 авг. 2023 г. в 19:35, Andrew Yushev <yush...@gmail.com>:

Dean D. Babic

unread,
Aug 17, 2023, 6:48:55 AM8/17/23
to Jam.py Users Mailing List
This is fantastic, thanks Andrew!

It can also be used with roles:

function on_filter_form_created(item) {
   if (task.user_info.role_id === 1) {    
       item.filters.customer.visible = true;
   }
   if (task.user_info.role_id === 2) {    
       item.filters.customer.visible = false;
   }

}

Ari Sobel

unread,
Aug 17, 2023, 11:21:06 AM8/17/23
to Dean D. Babic, Jam.py Users Mailing List
THAt's exactly what I am doing, Dean!

function on_filter_form_created(item) {
    if(task.user_info.role_id >1){
        item.filters.agent_ref.visible = false;
    }
}

Reply all
Reply to author
Forward
0 new messages