Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixSortColumn doesn't always run #5

Closed
dendeffe opened this issue Aug 10, 2012 · 1 comment
Closed

fixSortColumn doesn't always run #5

dendeffe opened this issue Aug 10, 2012 · 1 comment

Comments

@dendeffe
Copy link

In the function getManipulatedData, I moved the call to fixSortColumn to the front, because it doen't always run properly otherwise.

No idea if this is the best solution, though.

    /**
     * Manipulate the datalist as needed by this grid modifier.
     * @param GridField $gridField Grid Field Reference
     * @param SS_List $dataList Data List to adjust
     * @return DataList Modified Data List
     */
    public function getManipulatedData(GridField $gridField, SS_List $dataList) {
        $this->fixSortColumn($gridField, $dataList);
        $headerState = $gridField->State->GridFieldSortableHeader;
        $state = $gridField->State->GridFieldSortableRows;
        if ((!is_bool($state->sortableToggle) || $state->sortableToggle==false) && $headerState && !empty($headerState->SortColumn)) {
            return $dataList;
        }

        if ($state->sortableToggle == true) {
            $gridField->getConfig()->removeComponentsByType('GridFieldFilterHeader');
            $gridField->getConfig()->removeComponentsByType('GridFieldSortableHeader');
        }


        //Detect and correct items with a sort column value of 0 (push to bottom)



        return $dataList->sort($this->sortColumn);
    }
@UndefinedOffset
Copy link
Owner

I applied this change in master, now that I think about it. It does make sense to enforce the sort even if the toggle is not on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants