add class attributes to each cell
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 19 Jan 2016 09:44:37 +0000 (15:14 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 19 Jan 2016 09:44:37 +0000 (15:14 +0530)
CRM/Core/BAO/CustomValueTable.php
CRM/Custom/Page/AJAX.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl

index 66ec5737483385cb2a18d9f2e785ee36c716b523..85291f211b634026c279ddb90d185aacc40e4a78 100644 (file)
@@ -432,7 +432,7 @@ class CRM_Core_BAO_CustomValueTable {
 
     $limit = '';
     if (!empty($DTparams['rowCount']) && $DTparams['rowCount'] > 0) {
-      $limit = " LIMIT {$DTparams['offset']}, {$DTparams['rowCount']} ";
+      $limit = " LIMIT " . CRM_Utils_Type::escape($DTparams['offset'], 'Integer') . ", " . CRM_Utils_Type::escape($DTparams['rowCount'], 'Integer');
     }
 
     $orderBy = '';
index 65685deac0d48c6b663b71a24635ef7b8d11a3ac..37b1bd10f703c82e37dbb99890f442c2bd484848 100644 (file)
@@ -143,10 +143,13 @@ class CRM_Custom_Page_AJAX {
     $fieldList = array();
     foreach ($fields as $id => $value) {
       $field = array();
-      foreach ($value as $fieldId => $fieldName) {
+      foreach ($value as $fieldId => &$fieldName) {
+        if (!empty($attributes[$fieldId][$id]['class'])) {
+          $fieldName = array('data' => $fieldName, 'cssClass' => $attributes[$fieldId][$id]['class']);
+        }
         if (is_numeric($fieldId)) {
-          $fieldName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'label');
-          CRM_Utils_Array::crmReplaceKey($value, $fieldId, $fieldName);
+          $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'label');
+          CRM_Utils_Array::crmReplaceKey($value, $fieldId, $fName);
         }
       }
       $field = $value;
index b5b8db6138458ace520ac167008cd0af74e38958..685ffd8b98109f4c710776f42788d12784db6e3f 100644 (file)
@@ -369,7 +369,6 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
               }
               if ($editable) {
                 $fieldAttributes['class'] .= ' crm-editable';
-                $headerAttr[$fieldId]['class'] = 'crm-editable';
               }
               $attributes[$fieldId][$recId] = $fieldAttributes;
 
@@ -408,7 +407,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
                 $actionParams['cs'] = $pageCheckSum;
               }
 
-              $value['links'] = CRM_Core_Action::formLink(
+              $value['action'] = CRM_Core_Action::formLink(
                 $links,
                 $linkAction,
                 $actionParams,
index d6870cd4323abd85feb211a126c7e93780e7b4cf..e1d82c1c3d238686cb9459dda08524d27f46c9dc 100644 (file)
             <tr>
             {if $pageViewType eq 'customDataView'}
               {foreach from=$headers key=recId item=head}
-                <th data-data={ts}'{$head}'{/ts} cell-class="{$headerAttr.$recId.class}"
+                <th data-data={ts}'{$head}'{/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>
               {/foreach}
-              <th data-data="links" data-orderable="false">&nbsp;</th>
+              <th data-data="action" data-orderable="false">&nbsp;</th>
             </tr>
             </thead>
               {literal}
               <script type="text/javascript">
                 (function($) {
+                  var ZeroRecordText = {/literal}'{ts 1=$customGroupTitle}No records of type \'%1\' found.{/ts}'{literal};
                   $('table.crm-multifield-selector').data({
                     "ajax": {
                       "url": {/literal}'{crmURL p="civicrm/ajax/multirecordfieldlist" h=0 q="snippet=4&cid=$contactId&cgid=$customGroupId"}'{literal},
                     },
                     "aaSorting": [],
                     "pageLength": 10,
+                    "language": {
+                      "zeroRecords": 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].data != 'undefined') {
+                            $(cell).html(aData[fName].data);
+                          }
+                          if (typeof aData[fName].cssClass != 'undefined') {
+                            $(cell).attr('class', aData[fName].cssClass);
+                          }
+                        }
+                      });
+                      return nRow;
+                    },
                   })
+
                   $(".crm-multifield-selector").on('click','.delete-custom-row', function (e) {
                   var $el = $(this);
                   CRM.confirm({