Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
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
Partner Ambassador/MVP
Partner Ambassador/MVP

Brian,

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

-Rob

Anonymous
Not applicable
Author

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
Partner Ambassador/MVP
Partner Ambassador/MVP

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

Anonymous
Not applicable
Author

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.

Alexander_Thor
Employee
Employee

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
MVP
MVP

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

Astrato.io Head of R&D
Alexander_Thor
Employee
Employee

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

Anonymous
Not applicable
Author

Thanks Alexander, that gives me a place to start.

Anonymous
Not applicable
Author

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