Hi ,
All I want to set Default initial filter at Subpannel Select Button open popup…
open popup windo list view will be Set in filter or display record by default filter. .
Hi ,
All I want to set Default initial filter at Subpannel Select Button open popup…
open popup windo list view will be Set in filter or display record by default filter. .
See
You need to create a custom SugarWidget then edit the layoutdefs to use the custom SugarWidget and include the initial_filter_fields array definition in the TopSelectButton definition
Two steps to make this fix work:
Create a custom SugarWidget
Tell the subpanel to use the custom SugarWidget and add the initial_filter_fields array to the TopSelectButton definition
You can then use the custom SugarWidget in any other subpanel and the initial_filter_field will work
Create the custom SugarWidget
mkdir -p custom/include/generic/SugarWidgets/
cp -a include/generic/SugarWidgets/SugarWidgetSubPanelTopSelectButton.php custom/include/generic/SugarWidget/SugarWidgetSubPanelTopSelectButtonWithFilter.php
nano custom/include/generic/SugarWidgets/SugarWidgetSubPanelTopSelectButtonWithFilter.php
Change
class SugarWidgetSubPanelTopSelectButton extends SugarWidgetSubPanelTopButton
To
class SugarWidgetSubPanelTopSelectButtonWithFilter extends SugarWidgetSubPanelTopButton
Change
if (isset($widget_data['initial_filter_fields'])) {
if (is_array($widget_data['initial_filter_fields'])) {
foreach ($widget_data['initial_filter_fields'] as $value=>$alias) {
if (isset($focus->$value) and !empty($focus->$value)) {
$initial_filter.="&".$alias . '='.urlencode($value);
}
}
}
}
To
/*
* Edited Below to use the target module not the host module
* and to use the normal key=>value arrangement
if (isset($widget_data['initial_filter_fields'])) {
if (is_array($widget_data['initial_filter_fields'])) {
foreach ($widget_data['initial_filter_fields'] as $value=>$alias) {
if (isset($focus->$value) and !empty($focus->$value)) {
$initial_filter.="&".$alias . '='.urlencode($value);
}
}
}
}
*/
if (isset($widget_data['initial_filter_fields'])) {
if (is_array($widget_data['initial_filter_fields'])) {
foreach ($widget_data['initial_filter_fields'] as $alias=>$value) {
$initial_filter.="&".$alias . '='.urlencode($value);
}
}
}
Tell the subpanel to use the custom SugarWidget (in my case, editing the Events module (FP_events) subpanel I created pointing to Accounts … edit to suit your situation)
nano custom/Extension/modules/FP_events/Ext/Layoutdefs/fp_events_accounts_1_FP_events.php
Change
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
To
array (
'widget_class' => 'SubPanelTopSelectButtonWithFilter',
'mode' => 'MultiSelect',
'initial_filter_fields' => array(
'account_type_advanced' => 'Venue',
),
),
You will now be able to use the initial_filter_fields functionality in any subpanel by specifying the custom SugarWidget and including the initial_filter_fields array definition in the TopSelectButton definition.