Filtering directly on the table

Juan Parra
  • Juan Parra

    Juan Parra - 2008-11-14

    <div><br />In JPivot, I wish to introduce a change in navigation to allow filtering of data using the Navigator and extending TableComponentExtensionSupport.<br />The idea is<br /><br /><a href=""><img id="BLOGGER_PHOTO_ID_5268533040927054674" style="WIDTH: 320px; CURSOR: hand; HEIGHT: 198px" alt="" src="" border="0" /></a></div><div></div><br /><div>If the user clicks on the icon <a href=""><img id="BLOGGER_PHOTO_ID_5268534584845442962" style="WIDTH: 11px; CURSOR: hand; HEIGHT: 13px" alt="" src="" border="0" /></a> that will automatically filter the data.</div><div> </div>

    • Juan Parra

      Juan Parra - 2008-11-14

      my implementation is

      public class FilterMemberUI extends TableComponentExtensionSupport implements ModelChangeListener {

        public void initialize(RequestContext context, TableComponent table) throws Exception {
          super.initialize(context, table);

          table.getDispatcher().addRequestListener(null, null, dispatcher);

          AxisBuilder rab = table.getRowAxisBuilder();
          DomDecorator rhr = new DomDecorator(rab.getSpanBuilder());

          AxisBuilder cab = table.getColumnAxisBuilder();
          DomDecorator chr = new DomDecorator(cab.getSpanBuilder());


        class DomDecorator extends SpanBuilderDecorator {

          DomDecorator(SpanBuilder delegate) {

          public Element build(SBContext sbctx, Span span, boolean even) {
            Element parent =, span, even);

            if (!enabled || !renderActions)
              return parent;

            String id = DomUtils.randomId();
            if (isPosibleFilter(span)) {
              Element elem = table.insert("drill-expand", parent);
              elem.setAttribute("id", id);
              elem.setAttribute("img", "filter-member-aviable");
              elem.setAttribute("title", "Filtrar");
              dispatcher.addRequestListener(id, null, new FilterdHandler(span));
            return parent;


        static boolean isPosibleFilter(Span span) {

          if (!span.isMember()) return false;
          Member member = (Member) span.getMember().getRootDecoree();
          if (member.isAll())  return false;
          if (member instanceof MondrianMember ){
              MondrianMember mondrianMember = (MondrianMember)member;
              if (mondrianMember.getMonMember().isMeasure()) return false;
          Position position = (Position) span.getPosition().getRootDecoree();
          return indexOf(position.getMembers(), member) >= 0;

        protected void filter(Span span, RequestContext context) throws OlapException, Exception {

            MondrianMember mondrianMember = (MondrianMember) span.getMember().getRootDecoree();

            HttpSession session = context.getSession();

            Navigator navigator = (Navigator) session.getAttribute("navi01");

            Hierarchy hierarchy = span.getMember().getLevel().getHierarchy();

            HierarchyNavigator hierarchyNavigator = navigator.getHierarchyNav();


            HierarchyItem hi = hierarchyNavigator.findHierarchyItem(hierarchy);

            List list = new ArrayList();






    • Juan Parra

      Juan Parra - 2008-11-14

      this works but I had to change in the class HierarchyNavigator to public initializeCategories I think this is not good, any recommendation?

    • Carlos Dias

      Carlos Dias - 2008-11-14

      Sorry Juan, but I don't understand your question? Can you explain?!

    • Juan Parra

      Juan Parra - 2008-11-14

      Hi Carlos,

      A user asked me to filter directly into the data table through a icon.

      My idea was to use the HierarchyNavigator and HierarchyItem able to filter the data and that these changes are reflected in the Navigator.

      the click of the user returns the Span and through which I can get the MondrianMember and Hierarchy

      I could finally get the HierarchyItem using the method findHierarchyItem (hierarchy) of class HierarchyNavigator

      so we can enter the filter using the method setSelection ([MondrianMember ...]) of class HierarchyItem

      The problem was that the method findHierarchyItem (hierarchy) requires the field "List categories" not null

      This operation is done by the private method initializeCategories

      I had to switch to public and call initializeCategories before findHierarchyItem to make it work

      You can see the method protected void filter

      I think that change is not good and if there is any other way to perform this operation without having to change the existing source code.

      Thank you.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks