#475 (ok 3.3) Allow selecting a range of rows by holding shift

closed-accepted
nobody
Interface (183)
1
2010-03-07
2009-06-25
Joolee
No

It would be nice if one could select a range of checkboxes by using the shoft key. This is possible in GMail (just try it!)

Method:
Select a checkbox
hold shift and select a checkbox 10 rows lower.
All 11 rows should be checked now.

Discussion

  • Joolee

    Joolee - 2009-06-25
    • summary: Select ragne of rows --> Select range of rows
     
  • Joolee

    Joolee - 2009-06-25

    The following code will produce the effect.
    File phpmyadmin/js/functions.js (Revision 11695)
    Replace lines 521 to 550

    // ... and to mark the row on click ...
    rows[i].onmousedown = function(event) {
    var unique_id;
    var checkbox;
    var table;

            console.log\('onclick', this.rowIndex\);
    

    checkbox = this.getElementsByTagName( 'input' )[0];
    if ( checkbox && checkbox.type == 'checkbox' ) {
    unique_id = checkbox.name + checkbox.value;
    } else if ( this.id.length > 0 ) {
    unique_id = this.id;
    } else {
    return;
    }

    if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
    marked_row[unique_id] = true;
    } else {
    marked_row[unique_id] = false;
    }

    if ( marked_row[unique_id] ) {
    this.className += ' marked';
    } else {
    this.className = this.className.replace(' marked', '');
    }

    if ( checkbox && checkbox.disabled == false ) {
    checkbox.checked = marked_row[unique_id];
    if(typeof(event) == 'object') {
    table = this.parentNode;
    i = 0;
    while(table.tagName.toLowerCase() != 'table' && i < 20) {
    i++;
    table = table.parentNode;
    }

                    if\(event.shiftKey == true && table.lastClicked \!= undefined\) \{
                        event.preventDefault\(\);
                        i = table.lastClicked;
    
                        if\(i &lt; this.rowIndex\)
                            i++;
                        else
                            i--;
    
                        while\(i \!= this.rowIndex\) \{
                            table.rows\[i\].onmousedown\(\);
                            if\(i &lt; this.rowIndex\)
                                i++;
                            else
                                i--;
                        \}
    
                    \}
    
                    table.lastClicked = this.rowIndex;
                \}
    

    }
    }

     
  • Joolee

    Joolee - 2009-06-25

    Patchfile (Forgot to remove a console.log)

     
  • Marc Delisle

    Marc Delisle - 2009-06-25
    • labels: 317622 -->
     
  • Marc Delisle

    Marc Delisle - 2009-06-25

    Moved to patches.

     
  • Herman van Rink

    Herman van Rink - 2009-12-27
    • labels: --> Interface
    • summary: Select range of rows --> Allow selecting a range of rows by holding shift
    • priority: 5 --> 1
    • status: open --> open-accepted
     
  • Herman van Rink

    Herman van Rink - 2009-12-27
    • summary: Allow selecting a range of rows by holding shift --> (ok 3.3) Allow selecting a range of rows by holding shift
     
  • Marc Delisle

    Marc Delisle - 2010-03-07
    • status: open-accepted --> closed-accepted