1

I found the code in google groups posted by Massimo Di Pierro:

<button onclick="jQuery('input[type=checkbox]').each(function(k){jQuery(this).attr('checked', 'checked');});">select all</button>

I create this question because based on previous question that I post here, what if I retrieve a record from the Student Master List that reach 500+ or 1000+ and the table I create has no Select All button? it's hard to click and click and click and so on... anyone know where I will put that code? so that it's easy to retrieve record if the table has a select all checkbox on it.

MeSH
  • 101
  • 1
  • 10

3 Answers3

1

With

form = SQLFORM.smartgrid(..,selectable= lambda ids: your_function_name_to_trigger(ids),...),

add this to your controller function:

if form.elements('th'):
    form.elements('th')[0].append(SPAN('All', BR(), INPUT(_type='checkbox',
        _onclick="jQuery('input[type=checkbox]').each(function(k{jQuery(this)
            .attr('checked', 'checked'));});")))

This will 'check' all of the checkboxes in the form when clicking on the all button.

Draken
  • 3,134
  • 13
  • 34
  • 54
Serge
  • 11
  • 1
  • The code you pasted has some errors, but the idea works. I used the js code on the question but the idea here and it does what's needed – acaruci Mar 06 '18 at 12:10
0

Place the above code anywhere in the view where you want the button to be visible. It will find all checkboxes on the page.

Remco
  • 435
  • 3
  • 10
  • thanks for the reply Remco... I will try it later... Thanks also for the reply Gaura Vichare I think Remco solve my problem... – MeSH Oct 19 '15 at 00:21
0

I combined Serge answer with Jquery Checkbox check all solution, and works well:

if form.elements('th'):
    form.elements('th')[0].append(SPAN('All', BR(), INPUT(_type='checkbox',
    _onclick="jQuery('input:checkbox').not(this).prop('checked', this.checked);"
    )))
acaruci
  • 879
  • 9
  • 14