0 Replies Latest reply: Aug 22, 2018 4:17 PM by Luke Wileczek RSS

    Qlik Sense: Error in Navigation API. Binding to page

    Luke Wileczek

      I asked this question on stack overflow with no success: javascript - Qlik Sense: TypeError: Cannot read property 'interactionState' of null - Stack Overflow

       

       

      Background

      In Qlik Sense I took the QS Table extension and slightly modified it so that if I add a dimention that is the name of the other sheets in the app you can navigate to them by qliking the td element.

      My modifications to QS Table code:

      // added to the create rows function
      else if(~cell.qText.toLowerCase().indexOf('<sheet>')){
        
      var nameOfSheet = cell.qText;
        html
      += "QSsheetName' style='cursor: pointer;'"+'>'+nameOfSheet.slice(7, nameOfSheet.length)+'</td>';
      }

      // added a navigation function. Takes the text from the td element
      // and then uses it to find out the Sheet Id of the sheet with that
      // name and then uses the qlik.navigation api to go there.
      var app = qlik.currApp();
      function navigateToSheet ( sheetName ) {
        
      var allSheets = {};
        app
      .getList('sheet', function(reply) {
        $
      .each(reply.qAppObjectList.qItems, function(idx, value) {
        allSheets
      [value.qData.title] = value.qInfo.qId;
        
      });
        
      var mySheetId = allSheets[sheetName];
        qlik
      .navigation.gotoSheet(mySheetId);
        
      });
      };

      // added a listener in the Paint section to call navigation function on qlik
      $element
      .find("td.QSsheetName").on('click', function() {
       
      var elementText = $(this).text();
        navigateToSheet
      (elementText);
      });


      Problem

      If I click on one of the td elements in the QS table to navigate to sheet A it does navigate to sheet A, the intended sheet. However, if I leave sheet A and go to sheet B and click on anything interactive, say a point on a line chart, then I am automatically sent back to sheet A. The console doesn't always produce an error but it does report the following error sometimes:

      TypeError: Cannot read property 'interactionState' of null  
        at
      Class.c.onPaint (client.js?1522774745642:1) 
        at client
      .js?1522774745642:1 
        at a
      (require.js?1522774745642:1) 
        at
      require.js?1522774745642:1 
        at p
      .$eval (require.js?1522774745642:1) 
        at p
      .$digest (require.js?1522774745642:1) 
        at p
      .$apply (require.js?1522774745642:1) 
        at
      require.js?1522774745642:1 
        at o
      (require.js?1522774745642:1) 
        at
      require.js?1522774745642:1

      I added the line: console.log("table clicked")

      to my jQuery listener but it doesn't log anything after I click the table the first time. So the random navigations are cached somehow and not calling my listener function above. Can anyone help with this?