【问题标题】:Wix Display Results from refrenced table来自参考表的 Wix 显示结果
【发布时间】:2019-11-02 10:31:50
【问题描述】:

我在 wix 中有两个表:
Products
ProductCatgeories

Products 表有一个字段名称“type”,它引用到 ProductCatgeories 表

我正在尝试使用将显示产品标题及其类型的搜索结果填充表格元素。

    wixData.query("Products").contains("title", $w('#txtSearch').value).find().then((results) => {
    let items = results.items;}
$w('#tblSearch').rows = items;

以上工作正常! 但是它只显示 ProductCategories 表中的类型 ID。
我怎样才能做到这一点? 谢谢大家!

【问题讨论】:

    标签: database database-connection velo


    【解决方案1】:

    找到了!

    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;
    });
    

    你需要做的就是使用contain,它会立即连接refrnced table。

    您可以稍后通过调用它的列名后跟点和属性 IE 来访问它:

    productType.title
    

    就是这样!

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 2019-08-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-04
      • 2014-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多