public function makeSortable($db_field = null)
    {
        // reverse sorting
        $reverse = false;
        if ($db_field[0] == '-') {
            $reverse = true;
            $db_field = substr($db_field, 1);
        }

        // used db field
        if (!$db_field) {
            $db_field = $this->last_column;
        }

        switch ((string) $this->sortby) {

            // we are already sorting by this column
            case $db_field:
                $info = array('1', $reverse ? 0 : ('-'.$db_field));
                $this->sortby_db = $db_field;
                break;

            // We are sorted reverse by this column
            case '-'.$db_field:
                $info = array('2', $reverse ? $db_field : '0');
                $this->sortby_db = '-'.$db_field;
                break;

            // we are not sorted by this column
            default:
                $info = array('0', $reverse ? ('-'.$db_field) : $db_field);
        }

        $this->columns[$db_field]['sortable'] = $info;

        return $this;
    }
public function makeSortable($db_field = null)
    {
        // reverse sorting
        $reverse = false;
        if ($db_field[0] == '-') {
            $reverse = true;
            $db_field = substr($db_field, 1);
        }

        // used db field
        if (!$db_field) {
            $db_field = $this->last_column;
        }

        switch ((string) $this->sortby) {

            // we are already sorting by this column
            case $db_field:
                $info = array('1', $reverse ? 0 : ('-'.$db_field));
                $this->sortby_db = $db_field;
                break;

            // We are sorted reverse by this column
            case '-'.$db_field:
                $info = array('2', $reverse ? $db_field : '0');
                $this->sortby_db = '-'.$db_field;
                break;

            // we are not sorted by this column
            default:
                $info = array('0', $reverse ? ('-'.$db_field) : $db_field);
        }

        $this->columns[$db_field]['sortable'] = $info;

        return $this;
    }
public function makeSortable ( $ db_field = null ) { // reverse sorting $ reverse = false ; if ( $ db_field [ 0 ] == '-' ) { $ reverse = true ; $ db_field = substr ( $ db_field , 1 ) ; } // used db field if ( ! $ db_field ) { $ db_field = $ this -> last_column ; } switch ( ( string ) $ this -> sortby ) { // we are already sorting by this column case $ db_field : $ info = array ( '1' , $ reverse ? 0 : ( '-' . $ db_field ) ) ; $ this -> sortby_db = $ db_field ; break ; // We are sorted reverse by this column case '-' . $ db_field : $ info = array ( '2' , $ reverse ? $ db_field : '0' ) ; $ this -> sortby_db = '-' . $ db_field ; break ; // we are not sorted by this column default : $ info = array ( '0' , $ reverse ? ( '-' . $ db_field ) : $ db_field ) ; } $ this -> columns [ $ db_field ] [ 'sortable' ] = $ info ; return $ this ; }
Make sortable.

@param string $db_field

@return $this
Make sortable .