move aaSorting to markup and few fixes
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 19 Jan 2016 11:18:13 +0000 (16:48 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 19 Jan 2016 11:18:13 +0000 (16:48 +0530)
CRM/Custom/Page/AJAX.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
js/Common.js
templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl

index 37b1bd10f703c82e37dbb99890f442c2bd484848..ece28c55f37635c166574197cb12a4ca455e10b1 100644 (file)
@@ -139,7 +139,7 @@ class CRM_Custom_Page_AJAX {
 
     list($fields, $attributes) = $obj->browse();
 
-    // format params and add links
+    // format params and add class attributes
     $fieldList = array();
     foreach ($fields as $id => $value) {
       $field = array();
@@ -155,12 +155,13 @@ class CRM_Custom_Page_AJAX {
       $field = $value;
       array_push($fieldList, $field);
     }
+    $totalRecords = !empty($obj->_total) ? $obj->_total : 0;
     $fieldList = array_map('array_merge', $fieldList);
 
     $multiRecordFields = array();
     $multiRecordFields['data'] = $fieldList;
-    $multiRecordFields['recordsTotal'] = $obj->_total;
-    $multiRecordFields['recordsFiltered'] = $obj->_total;
+    $multiRecordFields['recordsTotal'] = $totalRecords;
+    $multiRecordFields['recordsFiltered'] = $totalRecords;
 
     CRM_Utils_JSON::output($multiRecordFields);
   }
index 685ffd8b98109f4c710776f42788d12784db6e3f..b37349b8e574245eb8e19fecc6413f6615645de1 100644 (file)
@@ -263,7 +263,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
       $DTparams = !empty($this->_DTparams) ? $this->_DTparams : NULL;
       // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
       $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE, $DTparams);
-      $resultCount = $result['count'];
+      $resultCount = !empty($result['count']) ? $result['count'] : count($result);
       unset($result['count']);
 
       if ($this->_pageViewType == 'profileDataView') {
index d821767a7738a07c518e635a1d84d2d71347260d..4ba35b2d26cd0dd1a1b39d5e5218a09f6176bd29 100644 (file)
@@ -731,6 +731,7 @@ if (!CRM.vars) CRM.vars = {};
       var defaults = {
         "processing": true,
         "serverSide": true,
+        "aaSorting": [],
         "dom": '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
         "pageLength": 25,
         "drawCallback": function(settings) {
index e1d82c1c3d238686cb9459dda08524d27f46c9dc..f38e65cf9702b0db75fd7c97a593fdf039340ca6 100644 (file)
@@ -30,7 +30,7 @@
   {else}
      {assign var='dialogId' value='profile-dialog'}
   {/if}
-  {if $records and $headers}
+  {if ($records and $headers) or ($pageViewType eq 'customDataView')}
     {include file="CRM/common/jsortable.tpl"}
     <div id="custom-{$customGroupId}-table-wrapper" {if $pageViewType eq 'customDataView'}class="crm-entity" data-entity="contact" data-id="{$contactId}"{/if}>
       <div>
                     "ajax": {
                       "url": {/literal}'{crmURL p="civicrm/ajax/multirecordfieldlist" h=0 q="snippet=4&cid=$contactId&cgid=$customGroupId"}'{literal},
                     },
-                    "aaSorting": [],
-                    "pageLength": 10,
                     "language": {
-                      "zeroRecords": ZeroRecordText,
+                      "emptyTable": ZeroRecordText,
                     },
                     //Add class attributes to cells
                     "fnRowCallback": function(nRow, aData) {
                       $('thead th').each( function( index ) {
                         var fName = $(this).attr('data-data');
                         var cell = $('td:eq(' + index + ')', nRow);
-                        if (typeof aData[fName]=='object'){
+                        if (typeof aData[fName]=='object') {
                           if (typeof aData[fName].data != 'undefined') {
                             $(cell).html(aData[fName].data);
                           }