top of page
Search
naveenaggarwal12

Bulk submit all region items to session state

Some time back I was building a search page with lots of filters on the left side of the screen (similar to Faceted Search).  In the middle of the page, I have created an Interactive Report that uses a function that returns the SQL query. There's a lot of logic going in there and I used the v function to fetch item values (no worries, SQL query uses only bind variables). It was just easier and faster than to put everything into input parameters. Also, I'm not a fan of using functions to return SQL queries, but in this case, it was a perfect match. 


The only problem was that I didn't want to submit the page to get item values into the session state nor to put all the items into region property Page Items to Submit (it's hard to handle that with lots of items). So I needed a quick and easy solution to submit all items from the filter region to the session state and here it is:


First, I've created a dummy AJAX Callback process, that doesn't do anything, just returns empty JSON object:



After that, I've created a simple JS function


functionfSearch(){
    varvItemArr=[];
    
    // loop through all filter items and push item IDs into JS Array
    $('#rgnFilter .apex-item-text,#rgnFilter .apex-item-radio, #rgnFilter .apex-item-select').each(function(){ 
            vItemArr.push($(this).attr('id'));
    });
    // call dummy AJAX process and send items array. on success, 
       refresh report
    apex.server.process("SUBMIT_ITEMS",
                        {pageItems:vItemArr},
                        {success: function(data) 
                        {apex.region('rgnReport').refresh()}}
                        );
  }

Function loops through region items (didn't test it for all possible item types in APEX), adds them to the JS array, and with the use of the feature of apex.server.process that you can put an array of item names in property pageItems, it submits them to the session state.

On success, it refreshes the Interactive Report region.


59 views0 comments

Recent Posts

See All

Comments


bottom of page