*/
function &getColumnHeaders($action = NULL, $output = NULL) {
$headers = NULL;
+
+ // unset return property elements that we don't care
+ if (!empty($this->_returnProperties)) {
+ $doNotCareElements = array(
+ 'contact_type',
+ 'contact_sub_type',
+ 'sort_name',
+ );
+ foreach ( $doNotCareElements as $value) {
+ unset($this->_returnProperties[$value]);
+ }
+ }
+
if ($output == CRM_Core_Selector_Controller::EXPORT) {
$csvHeaders = array(ts('Contact Id'), ts('Contact Type'));
foreach ($this->getColHeads($action, $output) as $column) {
$properties = self::makeProperties($this->_returnProperties);
foreach ($properties as $prop) {
- if ($prop == 'contact_type' || $prop == 'contact_sub_type' || $prop == 'sort_name') {
- continue;
- }
-
if (strpos($prop, '-')) {
list($loc, $fld, $phoneType) = CRM_Utils_System::explode('-', $prop, 3);
$title = $this->_query->_fields[$fld]['title'];
}
elseif (isset($this->_query->_fields[$prop]) && isset($this->_query->_fields[$prop]['title'])) {
$title = $this->_query->_fields[$prop]['title'];
- } else {
+ }
+ else {
$title = '';
}
if ($rowCount) {
$cacheKey = $this->buildPrevNextCache($sort);
$result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
+
+ // CRM-13996: result is empty when selector columns are sorted. hence we need to run the query again
+ if ( $result->N == 0) {
+ $result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
+ }
}
else {
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
$greeting = $property . '_display';
$row[$property] = $result->$greeting;
}
- elseif ($property == 'state_province') {
- $row[$property] = $result->state_province_name;
- }
elseif (isset($pseudoconstants[$property])) {
$row[$property] = CRM_Utils_Array::value(
$result->{$pseudoconstants[$property]['dbName']},