4 Replies Latest reply: Jun 16, 2011 7:28 AM by Dan English RSS

    [10sr2][Extension] How to filter more than 1 dimension in an extension

    Nicolas Stefaniuk

      Hello all.


      I am working on the marvellous new functionnality of Qlikview 10: the extensions. I have followed a tutorial here , opened the given extension and made some searchs on the net but I haven't found an answer to my question.


      When I create a basic table extension, which display an expression over 1 dimension, it works great. Lets call this extention the 1DimBasicTable. Filtering dimension in the page reduce data in the table and filtering the same dimension in the table reduce data in the page too.


      Dim 1Sum of Value




      But If I try to create an extension with 2 dimensions and 1 expression (2DimBasicTable), when I click on a value in 1 dimension, the data reduction is unpredicable. Sometimes the good dimension if filtered, sometimes not.


      Dim 1Dim 2Sum of Value


      I have tried to use:


      this.Data.SelectRow(i); where i is the ID of the line. It works well with 1 dimension but the data is reduced without logic when there is an other dimension. In this example, clicking on the column where Dim 1 = 'A' gives i = 0.


      this.Data.SelectValuesInColumn(j, columnValue); where j is the ID of the column in the table (for example 0 for the first, 1 for the second, etc.) and columnValue is the Value. In this example, clicking on the column where Dim 1 = 'A' gives j = 0 and columnValue = 'A'.


      Worst of all: if I load 2 dimensions in my model, and use only 1 in 1DimBasicTable, it works as bad as 2DimBasicTable. It looks like if QV is lost when there is more than 1 column to filter in the model. As all the examples use only 1 dimension, I don't know what is the good method to identify the column on which the filter should be applied, and if it's better to pass ID or value.


      If someone could give me some pointers or, better, an example, it would be great.


      Thanks a lot.

          • [10sr2][Extension] How to filter more than 1 dimension in an extension
            Dan English

            Hi nstefaniuk,


            Can you please go through your extension code and strip it down to the absolute bare essentials that will still demonstrate this issue. Can you then attach the extension and the QVW file to this tread. And can you also add click by click instructions to replicate the issue.


            If you can do all of that then I will take a look and see what I can tell you.



              • [10sr2][Extension] How to filter more than 1 dimension in an extension
                Nicolas Stefaniuk



                I have added my application and my extension to my original post.


                As you can see in my application, if you use the table with 1 dimension (based on Fact_2 and Dim1_2), it works

                great. Choosing a value of dimension Dim1_2 in the field applies the filter on the table and choosing a value of dimension Dim1_2 in the table applies the filter on the field.


                But it doesn't work with the table with 2 dimensions (based on Fact_1 and Dim1_1 and Dim2_1). Choosing a value of dimension Dim1_1 or Dim2_1 in the table applies something on the field, but I don't understand what. In fact in my code I have used  _this.Data.SelectRow(i), seen an example, but I don't really understand how it works and how I can use it to filter one dimension or an other one.


                Thanks a lot for the pointers.

                  • Re: [10sr2][Extension] How to filter more than 1 dimension in an extension
                    Dan English

                    Hi nstefaniuk,


                    Well it took me a bit to work this out as there are actually two separate issues here.


                    The first is a scoping issue. When you define onbasictablerowclick, you are defining it as a global, as soon as you add more than one instance of your extension object on a sheet, you end up overwriting the global function. That is why your selections always were happing in the same field regardless of which extension instance you clicked in.


                    The solution for that problem is to take the "this" in QvsAddExtension and add it as a member of your HTML table and then navigate up the DOM from your <TD> to the table to call the QlikView AJAX API function to execute the selection. By adding the "this" as a member of the <TABLE> you are free to add as many instances of your extension object as you would like (because each instance has it's own <TABLE>).


                    The second issue is in fact a bug when you call SelectRow with more than one dimension. I have logged it with support and the BugID is 39616.


                    The workaround is to use a different function to execute your selections (e.g. SelectTextsInColumn).


                    I have attached a script.js to this message that illustrates both solutions.


                    Thanks and regards,