Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
pnowicki
Creator
Creator

Widget Table with Dynamic Labels

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. 

1 Solution

Accepted Solutions
Stefan_Walther
Employee
Employee

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

View solution in original post

6 Replies
Stefan_Walther
Employee
Employee

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

pnowicki
Creator
Creator
Author

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.

Stefan_Walther
Employee
Employee

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

pnowicki
Creator
Creator
Author

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


pnowicki
Creator
Creator
Author

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>

Anonymous
Not applicable

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>