I’ve added a custom subpanel for the service module in the accounts module, using a custom query to fetch data. However, sorting in the subpanel isn’t working correctly; when I click on a column to sort, it loads all service module data instead of sorting the existing data. How can I troubleshoot and fix this sorting issue?
public/custom/Extension/modules/Accounts/Ext/Layoutdefs/accounts_j_services_1_Accounts.php
<?php
$layout_defs["Accounts"]["subpanel_setup"]['accounts_j_services_1'] = array(
'order' => 100,
'module' => 'j_Services',
'subpanel_name' => 'default',
'sort_order' => 'asc',
'sort_by' => 'id',
'generate_select' => true,
'title_key' => 'LBL_ACCOUNTS_J_SERVICES_1_FROM_J_SERVICES_TITLE',
'get_subpanel_data' => 'function:getRelatedServiceQueryData',
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/GetRelatedServiceQueryData.php',
'accountId' => $this->_focus->id
),
);
public/custom/modules/Accounts/GetRelatedServiceQueryData.php
<?php
function getRelatedServiceQueryData($param)
{
$accountId = $param['accountId'] ?? '';
$return_array['select'] = " SELECT j_services.id ,j_services.name,round(j_services.minimum_fee,2) AS 'minimum_fee',j_services.date_entered,j_services.date_modified, j_services_cstm.agency_c, j_services_cstm.years_c,j_services_cstm.service_category_c,leads.id AS 'LeadID',j_services_cstm.status_c,j_services_cstm.date_completed_c,j_services_cstm.date_cancelled_c ";
$return_array['from'] = " FROM j_services ";
$return_array['where'] = " j_services.deleted=0 AND leads.account_id='" . $accountId . "' ";
$return_array['join'] = " INNER JOIN leads_j_services_1_c ON leads_j_services_1_c.leads_j_services_1j_services_idb = j_services.id AND leads_j_services_1_c.deleted=0
LEFT JOIN leads ON leads.id = leads_j_services_1_c.leads_j_services_1leads_ida AND leads.deleted=0 ";
$return_array['join_tables'] = '';
return $return_arr
Is there any way to override sorting data in the subpanel, similar to how we override fetching data?