0

Unfortunately the searchColumns hook is not called by this form. It is a DataTable, but trying to use the stuff that is documented in the DataTable API (like .rows() or rowCreated do not seem to work either?

How can I manipulate a row from this dataTable and who would like to have a go at adding a dataTables chapter to the Developer Guide (or is it already there and am I missing it?)

1 Answer 1

1

There lots of screen that uses datatable to retrieve list of results which do not support any hooks to manipulate results or add additional clause or columns. We have altered the ajax request post/get data using jquery to send filters. In some cases it works, like in your case it may work if you want to filter it using campaign type. Here is a small snippet that i would call on the campaign dashboard page

{literal}
<script type="text/javascript">
CRM.$(function($) {
  $(document).ajaxSend(function(event, jqxhr, settings) {
    let url = decodeURIComponent(settings.url);
    if (url.indexOf('datatable/called/url') != -1
      && url.indexOf('[otherparameter]') != -1
    ) {
      if (!$('#campaign_type_id').val()) {
        settings.data = settings.url + '&searchCriteria=campaign_type_id&campaign_type_id=' + '1,2,3';
      }
    }
  });
});
</script>
{/literal}

The other alternative method is support hooks like selectWhereClause or rewrite whole logic to use api so that it can altered using hook a and submitting PR.

HTH

Pradeep

1
  • Thanks Pradeep. I believe it would be worthwhile to add a bit to the Developer Guide explaining how these admin pages can be influenced? Feb 3, 2020 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.