6 Replies Latest reply: Aug 10, 2017 5:38 AM by Martin Pallesen RSS

    Widget Table with Dynamic Labels

    Paul Nowicki

      I'm currently trying to create a widget table where I can have dynamic column labels.  This is my attempt at a workaround for Qlik Sense's lack of dynamic labels.  Has anyone done this before and can share their widget code?  If not, I'll keep working to either accomplish within a Widget or an extension. 

        • Re: Widget Table with Dynamic Labels
          Stefan Walther

          Hi pnowicki,

           

          unfortunately you run into the same limitation in Widget as in native objects, the in the data section you cannot define labels by expression.

          But I have found a workaround, have a look here: Table with dynamic label | qliksite.io

           

          Hope this helps.

          Regards

          Stefan

            • Re: Widget Table with Dynamic Labels
              Martin Pallesen

              Hi Stefan,

              Very nice workaround!

               

              A tip for other users:

              Sometimes the default labels in my datas are alright to use, but if I leave the "Custom labels" field blank, my column names are blank as well.

              So I used another of Stefans tutorials to add a checkbox which turns the custom labels on (default is off):

               

              <div ng-show="settings.showDetails">

                  {{settings.customLabels.split(';')[$index]}}

              </div>

              <div ng-hide="settings.showDetails">

                  {{head.qFallbackTitle}}

              </div>

            • Re: Widget Table with Dynamic Labels
              Paul Nowicki

              This is extremely helpful! In my attempts I also tried using custom fields to input my variables but then had a difficult time positioning them over the columns. This approach solves that problem and it is easy to work with.  Thanks again for your help Stefan.

                • Re: Widget Table with Dynamic Labels
                  Stefan Walther

                  Thx, please mark it as accepted answer then, so that others can more easily find it!

                  • Re: Widget Table with Dynamic Labels
                    Paul Nowicki

                    Now all I need to do is add a totals row!  To do so, I think I just need to figure out how to calculate a total inside the ng-repeat. I found a code snippet online that I'm currently trying to adapt to the html table provided by Stefan in the link above.  Also not sure if this is something that has already been done and is available.  See my failed attempt below.  If I find a way to get this to work I will post the solution. 

                     

                    My current (not working) table with totals:

                     

                    <table border="1" ng-init="cell.total = {}">

                        <thead>

                        <tr>

                            <th ng-repeat="head in data.headers">

                                {{settings.customLabel.split(';')[$index]}}

                            </th>

                        </tr>

                        </thead>

                        <tbody>

                        <tr ng-repeat="row in data.rows">

                            <td ng-repeat="cell in row.cells">

                                {{cell.qText}}

                            </td>

                        <td ng-init="cell.total.amount = cell.total.amount + cell.amount">{{cell.amount}}</td>

                      </tr>

                      <td>Total</td>

                      <td>{{cell.total.amount}}</td>

                        </tbody>

                    </table>


                    Similar request to this thread:

                    https://community.qlik.com/thread/223870


                      • Re: Widget Table with Dynamic Labels
                        Paul Nowicki

                        One of my team members figured out how to add the totals row, credits to Dan Swanda:

                         

                        <table border="1">

                            <thead>

                            <tr>

                                <th ng-repeat="head in data.headers">

                                    {{settings.customLabel.split(';')[$index]}}

                          </th>

                            </tr>

                            </thead>

                            <tbody>

                         

                            <tr ng-repeat="row in data.rows">

                                <td ng-repeat="cell in row.cells">

                                    {{cell.qText}}

                              

                          </td>

                          </tr>

                          <tr><td>Total</td>

                          <td ng-repeat="total in data.totals">

                          {{total.qText}}

                          </td>

                            </tr></tbody>

                        </table>