Customer Portal

Get Involved. Join the Conversation.

Topic

    Pathaksa Tongpitak
    Persistent Custom Report Filters when clicking Paginator
    Topic posted August 20, 2012 by Pathaksa TongpitakSilver Medal: 2,000+ Points 
    517 Views, 4 Comments
    Title:
    Persistent Custom Report Filters when clicking Paginator
    Content:

    Hi,

    I managed to add custom report filters

    Filter name = display_mode

    Filter  expression =  incident.c$unread (Yes/No Type)  EQUAL [ALL]

     

    The filter works perfectly when I open the page like this:

    http://site.custhelp.com/app/list/display_mode/1

    I have even created a custom Radio Report Filter Widget which has two options (All, Unread). By clicking on search, it will automatically append "display_mode/1" to the URL.

    However, when I click on the Paginator links, the filter is lost. The report gets refeshed using AJAX instead of new page loading.

    How do I keep persistent Custom Report Filters within this AJAX report refresh?

     

    Comment

     

    • Tracy Livengood

      The same filters that were applied to your original search should be applied to all subsequent searches performed by the pagination widget. Is it possible that you're reseting the filter when a search occurs? Could you provide a bit of the custom code that you're using to setup the filter?

       

      Thanks,
      Tracy L

    • Pathaksa Tongpitak

      Same happends when I insert a filter using an Hook:

       

        function PreReportGetHook($hookData)
          {
              $aContactIDFilter = array('100780', '100786');
            if(in_array($hookData['data']['reportId'], $aContactIDFilter))
            {
              $hookData['data']['filters']['c_id']->filters->fltr_id = 1;
              $hookData['data']['filters']['c_id']->filters->oper_id = 10;
              $hookData['data']['filters']['c_id']->filters->data = getContactID();
              $hookData['data']['filters']['c_id']->filters->rnSearchType = 'custom';
            }      

      }

       

      The report keeps reloading when refreshing the report and fetching data using AJAX when you try to sort a column or navigate through the paginator.

    • luke davison

       

      Hey Pathaksa,

      Is that the correct code for the pre_report_get hook? It is setting the c_id filter, but the OP refers to display_mode.

      Assuming display_mode as the filter, I would have your custom Radio Report Filter widget subscribe to the on_before_ajax_request event in JavaScript and adding the filter to the AJAX request for the reports that need them (100780 and 110786). In the logic.js file, you can add your on_before_ajax_requst event handler like such:

      RightNow.Event.subscribe("on_before_ajax_request", this._onBeforeAjaxRequest, this);
      

      Then, define the _onBeforeAjaxRequest handler using something like this in the widget's logic.js file (this code is untested):

      _onBeforeAjaxRequest: function(type, args) {
          if(args[0].post.filters && (args[0].post.report_id == 100780 || args[0].post.report_id == 110786)) {
              var filters = YAHOO.lang.JSON.parse(args[0].post.filters);
              filters.display_name = {
                  "w_id": this.instanceID,
                  "filters": {
                      "rnSearchType": "custom",
                      "report_id": args[0].post.report_id,
                      "data": {
                          "fltr_id": 1, // make sure this is correct for your report/filter
                          "oper_id": 10, // make sure this is correct for your report/filter
                          "val": 1, // should be 0/1 depending on radio selection
                      }
                  }
              };
              args[0].post.filters = YAHOO.lang.JSON.stringify(filters);
          }
      }
      
      
       
    • Pathaksa Tongpitak

      Hi Idavison,

      I was giving another example with lesser code.

      This is certainly the missing link for refreshing the report. I was suspecting this function was responsible I just didn't know how to implement it.

      Thanks a lot , I will test it and let you know if it works.