Results 1 to 1 of 1

Thread: subpanel filter (it works!)- critique needed

  1. #1
    Francescas's Avatar
    Francescas is offline Sugar Community Member
    Join Date
    Dec 2011
    Posts
    159

    Default subpanel filter (it works!)- critique needed

    We wanted users to be able to search within the subpanel without leaving the page.

    To achieve this I created a SugarWidget as follows:

    Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    //error_reporting(E_ALL);
    //ini_set('display_errors', 'On');
    require_once('include/generic/SugarWidgets/SugarWidgetSubPanelTopButton.php');
    
    class SugarWidgetSubPanelTopFilterInputButton extends SugarWidgetSubpanelTopButton
    {
       function SugarWidgetSubPaneliFilterInputButton($button_properties=array())
          {
              $this->button_properties=$button_properties;
          }
    
    function display(&$widget_data){
          $subpanel_definition = $widget_data['subpanel_definition'];
          $subpanel_name = $subpanel_definition->get_name();
          $module_name = ($_REQUEST['module']?$_REQUEST['module']:'');
          $id = ($_REQUEST['record']?$_REQUEST['record']:'');
          $prior_search_params[$subpanel_name] = trim($_REQUEST['search_params']?$_REQUEST['search_params']:'');
          if (isset($prior_search_params[$subpanel_name]) && $prior_search_params[$subpanel_name] != ''){
             echo("&nbsp;<i>Filter Applied:</i><b> " . $prior_search_params[$subpanel_name] . "  </b> <small>(click Filter with no parameters to remove filter)</small>");
          }
          $button = "<form><input type='text' id='filter_param_" . $subpanel_name . "' name='search_params' value='" . $prior_search_params[$subpanel_name] . "'>";
          $button .= "<input type='submit'  onclick=\"current_child_field = '" . $subpanel_name ."';
                                                      url='index.php?sugar_body_only=1&module=$module_name&subpanel=$subpanel_name&entryPoint=filter_subpanel&inline=1&record=$id&layout_def_key=$module_name&search_params=' + escape(document.getElementById('filter_param_' + current_child_field).value) ;
                                                      showSubPanel('".$subpanel_name ."',url,true,'" . $module_name . "');
                                                      document.getElementById('show_link_" . $subpanel_name . "').style.display='none';
                                                      document.getElementById('hide_link_" . $subpanel_name . "').style.display=''; 
                                                      return false;
                                                    \" 
                       href='#' value='Filter'></form>";
          return $button;
       }
    }
    
    ?>
    The custom entry point filter_subpanel.php is a modified version of include/SubPanel/SubPanelViewer.php where the subpanel definition is manipulated to set the where clause.
    Last edited by francescas@wolfram.com; 2012-02-02 at 03:30 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How To add a filter in subpanel popup
    By phanmca in forum Developer Help
    Replies: 0
    Last Post: 2011-12-07, 08:40 AM
  2. Filter Subpanel
    By peppe165 in forum General Discussion
    Replies: 1
    Last Post: 2011-05-06, 02:03 PM
  3. Subpanel filter with PHP
    By andi in forum Help
    Replies: 0
    Last Post: 2009-07-17, 10:59 AM
  4. Subpanel Filter
    By molson150 in forum Developer Help
    Replies: 2
    Last Post: 2009-04-17, 10:36 PM
  5. Filter On Subpanel
    By emeszaros in forum Developer Help
    Replies: 2
    Last Post: 2008-10-10, 06:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •