From f5eda27f1f3154cf67544da6e62bca5020fe59f2 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 19 Jan 2016 16:48:13 +0530 Subject: [PATCH] move aaSorting to markup and few fixes --- CRM/Custom/Page/AJAX.php | 7 ++++--- CRM/Profile/Page/MultipleRecordFieldsListing.php | 2 +- js/Common.js | 1 + .../CRM/Profile/Page/MultipleRecordFieldsListing.tpl | 8 +++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CRM/Custom/Page/AJAX.php b/CRM/Custom/Page/AJAX.php index 37b1bd10f7..ece28c55f3 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -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); } diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 685ffd8b98..b37349b8e5 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -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') { diff --git a/js/Common.js b/js/Common.js index d821767a77..4ba35b2d26 100644 --- a/js/Common.js +++ b/js/Common.js @@ -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) { diff --git a/templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl b/templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl index e1d82c1c3d..f38e65cf97 100644 --- a/templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl +++ b/templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl @@ -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"}
@@ -56,17 +56,15 @@ "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); } -- 2.25.1