Fixed issue with ajax calls on custom field table tab on contact.
authorMattias Michaux <mattias.michaux@gmail.com>
Wed, 4 May 2016 05:41:13 +0000 (07:41 +0200)
committerMattias Michaux <mattias.michaux@gmail.com>
Wed, 4 May 2016 05:41:13 +0000 (07:41 +0200)
CRM/Custom/Page/AJAX.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl

index 1bd938996f71f4740ad56f0416998174cafd8c88..7bb96f7d24565854b465f330f2a2390ac588507d 100644 (file)
@@ -125,11 +125,8 @@ class CRM_Custom_Page_AJAX {
     $obj->_contactType = $contactType;
     $obj->_DTparams['offset'] = ($params['page'] - 1) * $params['rp'];
     $obj->_DTparams['rowCount'] = $params['rp'];
-    if (isset($params['_raw_values']['sort'][0])) {
-      // Will this work when CiviCRM is translated, as searching happens on the label column?
-      // I can't find a place where the sort is added, but it should use the name, not the label.
-      $sort = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $params['_raw_values']['sort'][0], 'column_name', 'label');
-      $obj->_DTparams['sort'] = $sort . ' ' . $params['_raw_values']['order'][0];
+    if ($params['sortBy']) {
+      $obj->_DTparams['sort'] = $params['sortBy'];
     }
 
     list($fields, $attributes) = $obj->browse();
@@ -143,7 +140,7 @@ class CRM_Custom_Page_AJAX {
           $fieldName = array('data' => $fieldName, 'cellClass' => $attributes[$fieldId][$id]['class']);
         }
         if (is_numeric($fieldId)) {
-          $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'label');
+          $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'column_name');
           CRM_Utils_Array::crmReplaceKey($value, $fieldId, $fName);
         }
       }
index c27eb1953f960ca7b99c57b822c8566d12d07c77..88410a1d2f24a9129a89cf3cc6fd299c44c3f8bf 100644 (file)
@@ -428,6 +428,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
     if (!empty($fieldIDs)) {
       foreach ($fieldIDs as $fieldID) {
         $headers[$fieldID] = ($this->_pageViewType == 'profileDataView') ? $customGroupInfo[$fieldID]['fieldLabel'] : $fieldLabels[$fieldID]['label'];
+        $headerAttr[$fieldID]['columnName'] = $fieldLabels[$fieldID]['column_name'];
       }
     }
     $this->assign('dateFields', $dateFields);
index 5f6f091b58579bc1122a118f88a4be72c465953f..4e3824e19bcf0a815dce7bf5bb1dc6367d9cbae9 100644 (file)
@@ -40,7 +40,7 @@
             <tr>
             {if $pageViewType eq 'customDataView'}
               {foreach from=$headers key=recId item=head}
-                <th data-data={ts}'{$head}'{/ts}
+                <th data-data={ts}'{$headerAttr.$recId.columnName}'{/ts}
                 {if !empty($headerAttr.$recId.dataType)}cell-data-type="{$headerAttr.$recId.dataType}"{/if}
                 {if !empty($headerAttr.$recId.dataEmptyOption)}cell-data-empty-option="{$headerAttr.$recId.dataEmptyOption}"{/if}>{ts}{$head}{/ts}
                 </th>