use rowCallback
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 20 Jan 2016 10:49:08 +0000 (16:19 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 20 Jan 2016 10:49:08 +0000 (16:19 +0530)
CRM/Custom/Page/AJAX.php
templates/CRM/Contact/Page/View/CustomData.tpl
templates/CRM/Profile/Page/MultipleRecordFieldsListing.tpl

index ece28c55f37635c166574197cb12a4ca455e10b1..bfa703cd4619e40b584b74acdda48ca095b3a8b7 100644 (file)
@@ -145,7 +145,7 @@ class CRM_Custom_Page_AJAX {
       $field = array();
       foreach ($value as $fieldId => &$fieldName) {
         if (!empty($attributes[$fieldId][$id]['class'])) {
-          $fieldName = array('data' => $fieldName, 'cssClass' => $attributes[$fieldId][$id]['class']);
+          $fieldName = array('data' => $fieldName, 'cellClass' => $attributes[$fieldId][$id]['class']);
         }
         if (is_numeric($fieldId)) {
           $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'label');
@@ -156,7 +156,6 @@ class CRM_Custom_Page_AJAX {
       array_push($fieldList, $field);
     }
     $totalRecords = !empty($obj->_total) ? $obj->_total : 0;
-    $fieldList = array_map('array_merge', $fieldList);
 
     $multiRecordFields = array();
     $multiRecordFields['data'] = $fieldList;
index 865cad24f57a6b708da2d587399bb3d79cd85c20..68359ee16d3a3271bdda3ed6b99969b118adaf7a 100644 (file)
             CRM.$(function($) {
               var $table = $("#{/literal}custom-{$customGroupId}-table-wrapper{literal}");
               $('a.delete-custom-row', $table).on('click', function(e) {
-                var $el = $(this);
+                deleteRow($(this));
+                e.preventDefault();
+              });
+              $(".crm-multifield-selector").on('click', '.delete-custom-row', function (e) {
+                deleteRow($(this));
+                e.preventDefault();
+              });
+
+              function deleteRow($el) {
                 CRM.confirm({
                   message: '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal}'
                 }).on('crmConfirm:yes', function() {
@@ -60,8 +68,7 @@
                     CRM.refreshParent($el);
                   });
                 })
-                e.preventDefault();
-              });
+              }
             });
           </script>
         {/literal}
index f38e65cf9702b0db75fd7c97a593fdf039340ca6..31c560c43b7b2418ba62d56338b6ae2f7f1d2a4a 100644 (file)
                       "emptyTable": ZeroRecordText,
                     },
                     //Add class attributes to cells
-                    "fnRowCallback": function(nRow, aData) {
-                      $('thead th').each( function( index ) {
+                    "rowCallback": function(row, data) {
+                      $('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);
+                        var cell = $('td:eq(' + index + ')', row);
+                        if (typeof data[fName] == 'object') {
+                          if (typeof data[fName].data != 'undefined') {
+                            $(cell).html(data[fName].data);
                           }
-                          if (typeof aData[fName].cssClass != 'undefined') {
-                            $(cell).attr('class', aData[fName].cssClass);
+                          if (typeof data[fName].cellClass != 'undefined') {
+                            $(cell).attr('class', data[fName].cellClass);
                           }
                         }
                       });
-                      return nRow;
                     },
                   })
-
-                  $(".crm-multifield-selector").on('click','.delete-custom-row', function (e) {
-                  var $el = $(this);
-                  CRM.confirm({
-                    message: '{/literal}{ts escape='js'}Are you sure you want to delete this record?{/ts}{literal}'
-                  }).on('crmConfirm:yes', function() {
-                      var postUrl = {/literal}"{crmURL p='civicrm/ajax/customvalue' h=0 }"{literal};
-                      var request = $.post(postUrl, $el.data('delete_params'));
-                      CRM.status({/literal}"{ts escape='js'}Record Deleted{/ts}"{literal}, request);
-                      request.done(function() {
-                        CRM.refreshParent($el);
-                      });
-                    })
-                    e.preventDefault();
-                  });
                 })(CRM.$);
               </script>
               {/literal}