TACTIC Open Source
Behavior: how to get selected elements from 'ViewPanelWdg'/'TableLayoutWdg'? - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: Behavior: how to get selected elements from 'ViewPanelWdg'/'TableLayoutWdg'? (/showthread.php?tid=268)



Behavior: how to get selected elements from 'ViewPanelWdg'/'TableLayoutWdg'? - stefanovilla - 08-16-2022

Hello there,
I've been working on a custom widget, extended from class 'BaseRefreshWdg'.
It has two areas: on the left there's a list of existing entities. On the right there'll be details and stuff related to selected items.
Items are selected by checking the checkbox on the left of the ViewPanel/TableLayout.

I've created the left div using 'ViewPanelWdg' (or 'TableLayoutWdg') and I've tried to add a new behavior which should get the list of selected items and pass them, within kwargs, to the right div.

And that is where I got stuck, as I know basically nothing of JS and I couldn't find any example on how to get a list of all search_keys whose checkbox is set.
Any suggestions?
Many thanks, regards,
Stefano





..
...
episode_div =  TableLayoutWdg(search_type='{}/episode'.format(project_code), view='super_basic')
behavior['project_code'] = project_code
episode_div.add_class('episode_listing')
episode_div.add_behavior(behavior)
main.add(episode_div)

episode_list_div = DivWdg()
episode_list_div.add_class('episode_stuff')
episode_list.add(PreProductionAssemblyListWdg(project_code=project_code))
main.add(episode_list)
...
..




behavior = {'type': 'click',

            'cbjs_action': '''
                            let value = bvr.src_el.value;
                            let top = bvr.src_el.getParent(".system_top");
                            let episode_stuff = top.getElement(".episode_stuff");
                            let filter = spt.api.get_input_values( episode_stuff );
                               
                              let search_keys = ""
                           
                              //let episode_listing = top.getElement(".episode_listing");
                            //search_keys = spt.dg_table.get_selected_search_keys(episode_listing);
                               
                               
                            let kwargs = {
                                search_keys : search_keys,
                                project_code : bvr.project_code,
                                category_filter: "3",
                                filter: filter
                            };
                   
                            spt.panel.load(episode_stuff, "PreProductionAssemblyWdg.PreProductionAssemblyListWdg", kwargs);
                            '''
            }