10 Replies Latest reply: Mar 17, 2014 3:18 PM by Brian Garland RSS

    Custom Text or Button Object

    Brian Garland

      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?

        • Re: Custom Text or Button Object
          Rob Wunderlich

          Brian,

           

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

           

          -Rob

            • Re: Custom Text or Button Object
              Brian Garland

              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).

                • Re: Custom Text or Button Object
                  Rob Wunderlich

                  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

                    • Re: Custom Text or Button Object
                      Brian Garland

                      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.

                        • Re: Custom Text or Button Object
                          Alexander Karlsson

                          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[i];

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

                                    Get the object through qv.getobject then {

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

                                    }

                               }

                            };

                          });

                        • Re: Custom Text or Button Object
                          Michael Solomovich

                          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