Hide expandable rows ">" for rows that do not have children?

I only want users to be able to expend products that has parts.

TableProduct with ProductID
TablePartProductXref with ProductID and PartID
TablePart with PartID

Table for products (expandable table - Product_table)
Select
PRO.*
, IF(TPP.PartProductID > 0,'Yes','No') AS 'Has Parts'
From TableProducts PRO
Left Join TablePartProductXref TPP ON TPP.ProductID = PRO.ProductID
;
Table listing parts for product (child table - Part_table)
Select *
From TablePart TSP
INNER JOIN TablePartProductXref TPP ON TPP.PartID = TSP.PartID
Where TPP.ProductID = {{product_table.selectedRow.ProductID}}
;

I'm get:
image

This is what I want:
image

Is there some settings to do this?

I have minimal experience with Javascript. If a script is needed. Please help with a code.

In advance,
Thank you for your help

Hi there,

Thanks for reaching out to us! Unfortunately, the carrots will appear on each row. However, you can create a script that runs on Row Select that only expands the row on a condition.

table1.selectedRow.parameter ? table8.expandRows({

mode: "key",

key: table1.selectedRow.id

}) : ""

Would that work here?

Hi and Thanks for this.

unfortunately I'm a new beginner and need some more help with this.

  1. Where should I use the script in ReTool, on Event handlers or in my SQL as parameter?
  2. If I use my tables name is the script correct?

Select *
From TablePart TSP
INNER JOIN TablePartProductXref TPP ON TPP.PartID = TSP.PartID
Where TPP.ProductID = {{TableProduct.selectedRow.parameter ? TablePart.expandRows({

mode: "key",

key: TableProduct.selectedRow.PartID

}) : ""}}

In advance thank you

Hi apologies for the lack of clarification here.

The script will be for the table upon clicking a row.

So I'd imagine something like table1.selectedRow.partName ? or however your table is setup.

Possibly an if statement may work here instead. Such as
if(table1.selectedRow.partName){

table1.expandRows({

mode: "key",

key: table1.selectedRow.id

});

query1.trigger()

}

Then your SQL query can be triggered to get the part information. That way in the SQL query you can write it as WHERE partName = table1.selectedRow.partName . Would that work here?

+1

1 Like