7 Replies Latest reply: Mar 10, 2016 3:30 AM by corrado Chinotto RSS

    How can I create a filterPane from properties?

    corrado Chinotto

      I'm trying to create a filterPane properties by following the example:

      Create a filter pane ‒ Qlik Sense

       

       private IFilterpane CreateFilterpaneWithProperties(ISheet sheet) { var properties = new FilterpaneProperties { Title = "Filterpane", HyperCubeDef = new VisualizationHyperCubeDef { Mode = NxHypercubeMode.DATA_MODE_FILTERPANE, SuppressMissing = true, ReductionMode = NxDataReductionMode.DATA_REDUCTION_NONE, InterColumnSortOrder = new[] { 0 }, InitialDataFetch = new[] { new NxPage { Height = 50, Left = 0, Top = 0, Width = 50 } }, Measures = new[] { new HyperCubeMeasureDef { Def = new HyperCubeMeasureqDef { AutoSort = true, NumFormatFromTemplate = true, Def = "Sum(Expression1)", } } }, Dimensions = new[] { new HyperCubeDimensionDef { Def = new HyperCubeDimensionqDef { FieldDefs = new []{"Num"}.ToArray(), Grouping = NxGrpType.GRP_NX_NONE, AutoSort = true, OthersLabel = "Others", CId = ClientExtension.GetCid(), SortCriterias = new [] { new SortCriteria { SortByNumeric = SortDirection.Ascending, SortByLoadOrder = SortDirection.Ascending, Expression = string.Empty, } } }, OtherTotalSpec = new OtherTotalSpecProp { OtherCounted = "10", OtherLimit = "0", OtherLimitMode = OtherLimitMode.OTHER_GE_LIMIT }, TotalLabel = "Totals", } } } }; return sheet.CreateFilterpane("Filterpane", properties); }

      See also:

      but in the 2.2 SDK version verifa a mistake when I write

      "HyperCubeDef = new VisualizationHyperCubeDef" because the property HyperCubeDef not exist into "FilterpaneProperties"

       

       

      Can you tell me a working example with one or two listbox?

       

      Thanks Corchi

        • Re: How can I create a filterPane from properties?
          Øystein Kolsrud

          Hi! The filterpane example you point to is not correct and I will make sure we fix it as soon as possible. As you yourself has discovered, there is no HyperCubeDef property on filterpanes. Thanks for bringing this to our attention!

           

          As for the problem your are trying to solve, the filter pane differs somewhat from the other visualizations in that it does not contain any data directly. Instead, a filterpane should be viewed as a container of a set of list boxes (Listbox Class) which in turn holds a ListObject definition as part of its property set (ListboxProperties.ListObjectDef Property). This means that if you want to create a filterpane based on a FilterpaneProperties instance, then you will need to both create the filterpane and its Listbox children.

           

          However, the .Net SDK includes some convenience functions for creating visualization object that I think might be of interest to you. In particular you might want to check out the following methods:

           

          Qlik.Sense.Client.ISheet.CreateFilterpane(String, FilterpaneDataContainer)

          Qlik.Sense.Client.ISheet.CreateFilterpane(String, FilterpaneProperties)

          Qlik.Sense.Client.ISheet.CreateFilterpane(String,Object[])

           

          If I you want to create a filterpane containing a dimension based on a field named "Num" (like it looks like the example you pointed to tries to do), then you could do that with the following call:

           

          mySheet.CreateFilterpane(null, "Num");

           

          If you want to use more fields (for instance a filterpane that allows you to filter on country and year) you could write something like this (where the strings match field names):

           

          mySheet.CreateFilterpane(null, "Country", "Year");

           

          The fact that the first argument is null in these examples will cause the engine to select a unique ID for the newly created object.

            • Re: How can I create a filterPane from properties?
              corrado Chinotto

              Thanks, but what I'm trying to do is create a filterpane with filterpaneproperties : "Qlik.Sense.Client.ISheet.CreateFilterpane(String, FilterpaneProperties)"  .

              I have already tested the other two cases, and them working , now I want test the case with filterpaneproperties, can you post me a simple example?


              Thanks

               

                • Re: How can I create a filterPane from properties?
                  Øystein Kolsrud

                  In that case you will have to manually create the listbox children of the filterpane. It should look something like this:

                   

                  var filterpane = sheet.CreateFilterpane(null, filterpaneProperties);

                  var fields = new[] { "Country", "Year" };

                  foreach (var field in fields)

                  {

                      var props = new ListboxProperties

                      {

                          Info = new NxInfo { Type = "listbox" },

                      };

                    

                      props.ListObjectDef.Def = new ListboxListObjectDimensionDef

                      {

                          FieldDefs = new[] {field},

                      };

                      filterpane.CreateChild<Listbox>(props);

                  }

                    • Re: How can I create a filterPane from properties?
                      corrado Chinotto

                      ok thanks now it works!!!!!

                      ...

                      I noticed that to create a simple Listbox just write :

                      Example1:

                                 var properties = new ListboxProperties()

                                  {

                                      Title = sTitle,

                                      ListObjectDef = new ListboxListObjectDef

                                      {

                                          InitialDataFetch = new[] { Pager.Default },

                                          Def =  new ListboxListObjectDimensionDef

                                          {

                                              FieldDefs = dimensionList,

                                              FieldLabels = dimensionListLabel,

                                              CId = ClientExtension.GetCid(),

                                           }

                                      }

                                  };

                                  sheet.CreateListbox("ListBox", properties);

                       

                      whereas if I want to create the same listbox inside a filterpane I have to add mandatory " Info = new NxInfo { Type = "listbox" }", otherwise it does not work !!! you know give me an explanation?

                       

                       

                      Example2:

                                 var properties = new ListboxProperties()

                                  {

                                      Title = sTitle,

                                     Info = new NxInfo { Type = "listbox" }",

                                      ListObjectDef = new ListboxListObjectDef

                                      {

                                          InitialDataFetch = new[] { Pager.Default },

                                          Def =  new ListboxListObjectDimensionDef

                                          {

                                              FieldDefs = dimensionList,

                                              FieldLabels = dimensionListLabel,

                                              CId = ClientExtension.GetCid(),

                                           }

                                      }

                                  };

                                  sheet.CreateListbox("ListBox", properties);

                       

                       

                       

                      PS. This must be corrected in our example

                      Create a list box ‒ Qlik Sense

                       

                       

                      Anyway, thanks very much for the speed in responding, you have saved me a lot of time!!!!!!!!

                        • Re: How can I create a filterPane from properties?
                          Øystein Kolsrud

                          Did you use the method Filterpane.CreateChild or the method Filterpane.CreateListbox when you had problems with the NxInfo setting? You shouldn't have to state the NxInfo if you use the CreateListbox version. In fact, I realize now that my example above could be simplified to this if I had use the CreateListbox method instead:

                           

                          var filterpane = sheet.CreateFilterpane(null, filterpaneProperties);

                          var fields = new[] { "Country", "Year" };

                          foreach (var field in fields)

                          {

                              var props = new ListboxProperties();

                              props.ListObjectDef.Def = new ListboxListObjectDimensionDef

                              {

                                  FieldDefs = new[] {field},

                              };

                              filterpane.CreateListbox(null, props);

                          }

                          • Re: How can I create a filterPane from properties?
                            Øystein Kolsrud

                            Oh, and I think actually the list box examples you pointed to are correct. The background here is that the child creating methods (for instance the method Filterpane.CreateListbox) know the type it is going to create, so if you haven't already specified the NxInfo in the properties argument to the method, then the method will fill it in for you. However, the basic GenericObject.CreateChild method does not have all information available so it can't do it for you.

                             

                            And the reason why the type is not set by the properties constructor is that it is not always the case that a properties instance representing for instance a Listbox has the type "listbox". It could also be a master object in which case the properties would very much resemble a listbox, but the type will be set to "masterobject".