Qlik Community

QlikView Extensions

Discussion Board for collaboration on QlikView Extensions.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

bgarland
Not applicable

Custom Text or Button Object

So I have need of what I think is a pretty simple extension, but I'm getting nowhere trying to create it myself. All I'm trying to do is create a text object or button (need to have an Action attached when clicked) that shows the number of rows of a specified chart. For example, CH01 is a chart of sales orders on hold and the custom text object would say "Orders currently on hold: 99". The extension would allow you to specify the object ID that has the rows you need counted. The user could then click on this and the chart would open/become visible. Does anyone have any guidance on creating such as extension?

10 Replies
rwunderlich
Not applicable

Re: Custom Text or Button Object

Brian,

Why an extension? Why not just a text box that makes the calculation?

-Rob

bgarland
Not applicable

Re: Custom Text or Button Object

That would require a macro to make the API call, which is what I'm already doing. But I'm trying to make the switch over to web view so a macro is no longer an option (i'm trying to get away from macros).

rwunderlich
Not applicable

Re: Custom Text or Button Object

It sounds like you want to physically count the rows, which is difficult. Are you thinking of getting  a handle to the chart and counting the number of <tr> elements or something like that?

I usually just calculate the number in an expression that simulates what's in the table.

-Rob

bgarland
Not applicable

Re: Custom Text or Button Object

My original desire was to place the number of rows directly in the caption of my minimized charts without needing to rely on using the same set analysis expressions as are in the chart. So, since I wanted to switch to web view and ditch macros anyway, I thought another option would be a simple extension object that could fetch the row count. With about thirty charts, I could place multiple instances of this extension and let the users click on them to open the associated charts.

edit:  the goal is to give the users a way to know if minimed charts actually contain data, given any current selections, without needing to  restore or maximize each chart.

akl
Not applicable

Re: Custom Text or Button Object

Getting the row count of a chart would be quite easy. However you also want to maximize charts as actions which will be harder. Not to mention that you would have to attach callbacks to about thirty charts that would have to run on every update.

Here is some pseduo code to get you started, it will append the row count for every chart on the page to the caption.

Disclaimer: I haven't tested it but should work in theory

Qva.AddDocumentExtension('YourExt', function() {

  var $doc = Qv.GetCurrentDocument();

  $doc.GetAllObjects(function(objects) {

  for (var i = 0; i < objects.length; i++)

  {

     var obj = objects;

     if(obj.Type === 'CH') {

          Get the object through qv.getobject then {

                this.Layout.SetProperty('Caption.Text', 'My Row Count: ' + this.Data.TotalSize.y, true);

          }

     }

  };

});

rbecher
Not applicable

Re: Custom Text or Button Object

Btw. would be nice to have similar function for this.Data.TotalSize.y in QlikView itself..

akl
Not applicable

Re: Custom Text or Button Object

Ye it's coming, we will be binding it to the angular scope in the next major release.

bgarland
Not applicable

Re: Custom Text or Button Object

Thanks Alexander, that gives me a place to start.

mov
Not applicable

Re: Custom Text or Button Object

Ditto.

The number of rows is mostly defined by the combination of dimensions and may include additional rules based on expressions (e.g. for "suppress zero-values").  No macro, no extensions.

Regards,

Michael