• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Grabbing data from a widget with a script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grabbing data from a widget with a script

    After data is loaded on a Pivot Widget, I want to execute a script (using a button inside the Pivot widget). This script utilizes pdfmake to generate a PDF that is a reformatted pivot table that can be printed. Inside this reformatted pivot table, I want the data from the Pivot widget to load on the PDF.

    What is the method to grab the data from Pivot widget utilizing a script and pdfmake so it can load on the PDF?

    Thanks

  • #2
    We don't have an officially supported way for you to get the data and then create a PDF. However, below is an example that will help you retrieve the data. It will require some effort to pull the data you need and then create the PDF.

    Code:
    const baseWidget = getWidget('customerSales'),
          pivot      = baseWidget.down('pivotgrid'),
          exporter   = Ext.plugin.Manager.create({}, 'pivotexporter', pivot),
          data       = exporter.prepareData({onlyExpandedNodes:false});
    
    console.log('my pivot data : ', data);
    
    exporter.destroy();
    
    success();

    Comment


    • #3
      This works, thank you! A similar method would be helpful with the grid widget as well since I'll be able to grab each row generated and throw it onto a PDF. Is there documentation available with information on functions like baseWidget.down() so I can apply it to other widgets?

      Comment


      • #4
        Below is an example of how to retrieve data from a grid:

        Code:
        const widget = getWidget('gridOne');
        const uiComponent = widget.down('#uicomponent');
        const data = uiComponent.getStore().data;
        
        let ii, record;
        
        for (ii = 0; ii < data.items.length; ii++) {
            record = data.items[ii];
            console.log(record.data);
        }

        Comment


        • #5
          Originally posted by Johnny Major View Post
          Below is an example of how to retrieve data from a grid:

          Code:
          const widget = getWidget('gridOne');
          const uiComponent = widget.down('#uicomponent');
          const data = uiComponent.getStore().data;
          
          let ii, record;
          
          for (ii = 0; ii < data.items.length; ii++) {
          record = data.items[ii];
          console.log(record.data);
          }
          This works, thank you!

          Comment

          Working...
          X