diff --git a/code/GridFieldOrderableRows.php b/code/GridFieldOrderableRows.php index 3ce2538..d996152 100755 --- a/code/GridFieldOrderableRows.php +++ b/code/GridFieldOrderableRows.php @@ -280,9 +280,11 @@ class GridFieldOrderableRows extends RequestHandler implements if($list instanceof ManyManyList) { $extra = $list->getExtraFields(); $key = $list->getLocalKey(); + $foreignKey = $list->getForeignKey(); + $foreignID = '= ' . (int) $list->getForeignID(); if(array_key_exists($this->getSortField(), $extra)) { - return sprintf('"%s" %s', $key, $value); + return sprintf('"%s" %s AND "%s" %s', $key, $value, $foreignKey, $foreignID); } }