public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
    {
        // we fallback to nb_visits in case columnToSort does not exist
        $columnsToCheck = array($columnToSort, 'nb_visits');

        $row = $table->getFirstRow();

        foreach ($columnsToCheck as $column) {
            $column = Metric::getActualMetricColumn($table, $column);

            if ($row->hasColumn($column)) {
                // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
                return $column;
            }
        }

        return $columnToSort;
    }
public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
    {
        // we fallback to nb_visits in case columnToSort does not exist
        $columnsToCheck = array($columnToSort, 'nb_visits');

        $row = $table->getFirstRow();

        foreach ($columnsToCheck as $column) {
            $column = Metric::getActualMetricColumn($table, $column);

            if ($row->hasColumn($column)) {
                // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
                return $column;
            }
        }

        return $columnToSort;
    }
public function getPrimaryColumnToSort ( DataTable $ table , $ columnToSort ) { // we fallback to nb_visits in case columnToSort does not exist $ columnsToCheck = array ( $ columnToSort , 'nb_visits' ) ; $ row = $ table -> getFirstRow ( ) ; foreach ( $ columnsToCheck as $ column ) { $ column = Metric :: getActualMetricColumn ( $ table , $ column ) ; if ( $ row -> hasColumn ( $ column ) ) { // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column return $ column ; } } return $ columnToSort ; }
Detect the column to be used for sorting

@param DataTable $table
@param string|int $columnToSort  column name or column id
@return int
Detect the column to be used for sorting