Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter gabig

    (@gabig)

    First of all, thanks Michael. This must be the most stupid question ever asked on the forums. I fell ashamed. I made one test and probably misspelled a column name. Anyway I give you a link and a function that it maybe useful for other cases. It is a jquery code that does the same but it has a big flaw. The columns widths that you change stay the same so the headers and the rows below may not have the same width. What I’ve done is give them an exact width as a workaround.

    
    //switchColum 24 to 1 and 1 to 24
    $('#myid').switchColumns( 1, 24 );
    //switchColum 24 to 1 and 2 to 25
    
    $.fn.switchColumns = function ( col1, col2 ) {
        var $this = this,
            $tr = $this.find('tr');
        $tr.each(function(i, ele){
            var $ele = $(ele),
            $th = $ele.find('th'),
            $tht;
            $tht = $th.eq( col1 ).clone();
            $th.eq( col1 ).html( $th.eq( col2 ).html() );
            $th.eq( col2 ).html( $tht.html() );
     $th.css( {"max-width": "110px", "min-width": "110px"}) ; 
            var $ele = $(ele),
            $td = $ele.find('td'),
            $tdt;
            $tdt = $td.eq( col1 ).clone();
            $td.eq( col1 ).html( $td.eq( col2 ).html() );
            $td.eq( col2 ).html( $tdt.html() );
        });
    };

    Credits go to this thread:https://stackoverflow.com/questions/5464219/change-table-columns-order

    Now I have to create a page that shows the forms of the table in a form when you click on the Submitted column. But that’s another story ??

    Again, many thanks for answering

    • This reply was modified 7 years, 12 months ago by gabig.
Viewing 1 replies (of 1 total)