2 Replies Latest reply: Sep 20, 2013 2:55 AM by TobiP RSS

    Custom Rowtype Template with apex.widget.report.sort() - does this work?

    TobiP

      Hi Folks!

       

      I have a report with a custom rowtype template (3 rows for each dataset) and I have fiddeled around with the build-in javascript sorting-function. (Cause as it seems you can't use the standard sorting functionality on custom rowtemplates.) I came up with a short solution, but I would like to know how safe this is.

       

      Setup very simple:

      The Header-Template [before rows]

      <table id="myDomId">
          <thead><tr>
              <th><a href="javascript:sortCol(1)">Col1</a></th>
              <th><a href="javascript:sortCol(2)">Details</a></th>
              <th><a href="javascript:sortCol(3)">Col3</a></th>
          </tr></thead>
      
      
      
      

       

       

      Then the javascript handling runs like that:

      var qmmSorter = {};
      $(function(){
         setupSorters();
      });
      
      function setupSorters(){
          qmmSorter.DomCatch = /\d+/.exec($('#myDomId>div').attr('id'))[0];
          qmmSorter.lastCol = 1;
          qmmSorter.asc = true;
      };
      
      function sortCol(colnum){
      //console.log(colnum);
          if (qmmSorter.DomCatch) {
              qmmSorter.lastCol = colnum;
              qmmSorter.asc = !qmmSorter.asc;
              javascript:apex.widget.report.sort( qmmDomCatch,'fsp_sort_'+colnum + ( qmmSorter.asc ? '' : '_desc') );
          }
      }
      
      
      
      
      
      
      

       

      Maybe I'll also add some arrows to indicate what sorting took place. Tested so far in IE9 and Moz - all we really use in our internal network.

      But this seems all a bit just too easy. so I'd be really thankful for your comments.

       

      Tanks and greetings,

      Tobi

        • 1. Re: Custom Rowtype Template with apex.widget.report.sort() - does this work?
          fac586

          TobiP wrote:

           

          But this seems all a bit just too easy. so I'd be really thankful for your comments.

          It would be even easier to use column header substitution and retain the built-in sort functionality (although this includes the sort direction image bug).

           

          <table id="myDomId">  
            <thead><tr> 
              <th>#1#</th> 
              <th>#2#</th>  
              <th>#3#</th>  
            </tr></thead>
          

           



          • 2. Re: Custom Rowtype Template with apex.widget.report.sort() - does this work?
            TobiP

            Hi fac,

             

            I tried your suggestion, but now the table headers is not rendered at all. I guess it depends on the template type. Mine is "Named Column (row template)"  where you define the <thead> in the section " Before first and after last row text" (APEX 4.2)

            On the weekend I will build a testcase, to give you an impression of how it looks like now.


            My concern about my solution: Sometimes I have read, some build-in apex background functions should't be used on their own. E.g. what happenes after an Apex-upgrade? I don't want to have to monitor this always. (But this certainly touches a very general issue, and I am not yet that much of an experienced APEX pro.)