def index():
return dict( list_program = SQLFORM.grid(db.Program) )
<script>
jQuery(document).ready(function(){
jQuery('#btn_list_program').click(function(){ jQuery('#selected_form').html( '{{=list_program}}' ) });
</script>
<div class="container-fluid">
<div class="row">
<div class="col col-sm-2">
<div class="btn-group-vertical" role="group" style="width:100%">
<button id="btn_list_program" type="button" class="btn btn-outline-primary">ListProgram</button>
</div>
</div>
<div class="col offset-sm-1" id="form_wrapper">
<div id="selected_form"></div>
</div>
</div>
</div>
I have more than 1 grid on the same page (about 10). I could do it, but it is not a best solution because I need to keep track of which gird is visible, hide that grid, and show the new selected one. I hope there is a better way to solve this... wondering why it does not work. It works beautiful with form
jQuery('#visible_div').html(jQuery('#hidden_div_1').html());
[...]
3. "Also, rather than building all the grids when the page is first requested, you might consider loading each grid asynchronously via Ajax only when needed. For example, clicking a button could call $.web2py.component() to retrieve a given grid as a web2py Ajax component."
I don't know Ajax, could you please give me an example based on my code? Thanks
Thanks1. "you can instead put the grid HTML inside a Javascript template literal"You mean like this?jQuery('#btn_list_program').click(function(){ jQuery('#selected_form').html( `{{=list_program}}` ) });Unfortunately, this does not work