我在wix中有两个表:
产品
产品类别
“产品”表的字段名称为“类型”,该字段名称对应于“产品类别”表
我正在尝试用搜索结果填充一个完整的表,该搜索结果将显示产品标题及其类型。
wixData.query("Products").contains("title", $w('#txtSearch').value).find().then((results) => {
let items = results.items;}
$w('#tblSearch').rows = items;
以上工作正常!
但是它仅显示产品类别表中的类型ID。
我怎样才能做到这一点?
谢谢大家!
答案 0 :(得分:0)
找到了!
let cols = $w("#table1").columns;
cols = [];
cols.push({
"id": "type",
"dataPath": "productType.title",
"label": "ProductType",
"width": 70,
"visible": true,
"type": "string"
});
cols.push({
"id": "title",
"dataPath": "title",
"label": "product",
"width": 70,
"visible": true,
"type": "string"
});
$w('#table1').columns= cols;
wixData.query("Products").contains("title","חלב").include("productType").find().then((res)=>{
var prods= res.items;
console.log(prods[2]);
$w('#table1').rows=prods;
});
您需要做的就是使用contains,它将立即连接刷新的表。
您以后可以通过调用其列名后接点和属性IE来访问它:
productType.title
就是这样!