diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 2e10275f7..f268f081b 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -284,17 +284,22 @@ class DisplayBlock } - if ($this->m_sStyle != 'search') // Search form need to extract result list extra data, the simplest way is to expose this configuration + if ($this->m_sStyle == 'list') // Search form need to extract result list extra data, the simplest way is to expose this configuration { + + $listJsonExtraParams = json_encode(json_encode($aExtraParams)); $oPage->add_ready_script(" - $('#$sId').data('sExtraParams', \"$sExtraParams\"); - $('#$sId').data('bAutoReload', \"$sExtraParams\"); + $('#$sId').data('sExtraParams', ".$listJsonExtraParams."); + $('#$sId').data('bAutoReload', \"".(int) $bAutoReload."\"); console.debug($('#$sId').data()); console.debug($('#$sId')); console.debug('#$sId'); "); + + + // $oPage->add_ready_script("console.debug($('#Menu_UserRequest_OpenRequests').data());"); } diff --git a/pages/ajax.searchform.php b/pages/ajax.searchform.php index 741d83917..712e8b1c8 100644 --- a/pages/ajax.searchform.php +++ b/pages/ajax.searchform.php @@ -55,7 +55,7 @@ try $oDisplayBlock = new DisplayBlock($oFilter, 'list', false); $sListParams = stripslashes(utils::ReadParam('list_params', '{}', false, 'raw_data')); - $aListParams = json_decode($sListParams, true); + $aListParams = (array) json_decode($sListParams, true); $aPassFromExtraParamsToListParams = array( diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index 68eaa90c5..8f51a8100 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -146,7 +146,8 @@ class SearchForm } $aSearchParams = array( 'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer", - 'result_list_outer_selector' => "#{$aExtraParams['table_id']}", + 'result_list_outer_selector' => "#{$aExtraParams['table_id']}", + 'data_config_list_selector' => null, //this one will be set just bellow, it mean to tell the widget where to find the initial list configuration 'endpoint' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.searchform.php', 'list_params' => $aListParams, 'search' => array( @@ -156,6 +157,19 @@ class SearchForm ), ); + if (isset($aSearchParams['list_params']['table_inner_id'])) + { + $aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_inner_id']; + } + elseif (isset($aSearchParams['list_params']['table_id'])) + { + $aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_id']; + } + else + { + $aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['result_list_outer_selector']; + } + $oPage->add_ready_script('$("#fs_'.$sSearchFormId.'").search_form_handler('.json_encode($aSearchParams).');'); return $sHtml;