Displaying different child row data based on another column

Displaying different child row data based on another column

responsivelabsresponsivelabs Posts: 31Questions: 8Answers: 0
edited February 2020 in Free community support

So currently, I'm displaying a child row to display extra data that differs based on what category it is in which is pulled from a JSON file. The only thing is, I'm currently able to display the child row data for one category, but I'd like to have it to where it only displays it based on what category the parent row is in. Each parent row would have its own specific child row data, but again it would differ based on the category. There are about 9 categories, how would I go about doing this? Here is an example of my JSON data:

[{"id":"1234567fef","category":"cat1","nonce":2490,"currency":"usd","amount":1,"payoutMultiplier":0,"payout":0,"createdAt":"2020-01-19T00:07:13.930Z","updatedAt":"2020-01-19T00:07:13.930Z","stateCategory1":{"drawnNumbers":[21,37,39,8,19,10,35,11,29,12],"selectedNumbers":[6,21,10,16,26,12,36,31,1],"risk":"high"},"clientSeed":"123456"}

The data within stateCategory1 would be what I am trying to display. The data within it differs based on the category, however each category has the same number and types of data. Currently, I'm able to use this to display for a single category, but obviously I get an error thrown for parent rows that are in a different category:

  function format ( d ) {
      // `d` is the original data object for the row
      return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
          '<tr>'+
              '<td style="font-weight:bold;">Numbers Drawn:</td>'+
              '<td>'+d.stateCategory1.drawnNumbers+'</td>'+
          '</tr>'+
          '<tr>'+
              '<td style="font-weight:bold;">Selected Numbers:</td>'+
              '<td>'+d.stateCategory1.selectedNumbers+'</td>'+
          '</tr>'+
          '<tr>'+
              '<td style="font-weight:bold;">Risk Level:</td>'+
              '<td>'+d.stateCategory1.risk+'</td>'+
          '</tr>'+
      '</table>';
  }

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.