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:
This is what I want:
Is there some settings to do this?
I have minimal experience with Javascript. If a script is needed. Please help with a code.
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.
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?