wix以编程方式将表连接到产品页面



你好,我使用Wix平台创建了一个web商店,在将自定义编码表连接到产品页面时遇到问题。我的方法是,客户可以按标题搜索产品,结果会用自定义字段填充一个表。我遇到的问题是,我希望客户能够点击一行,然后导航到显示他们点击的产品的产品页面。这是我从API文档中获得的JSON对象形式的表,并替换了我自己的属性(工作正常(:

$w('#table1').columns = [{
"id": "col1", // ID of the column for code purposes
// The field key in the collection whose data this column displays  
"dataPath": "mainMedia",
"label": "Image", // The column header
"width": 100, // Column width
"visible": true, // Column visibility
"type": "image", // Data type for the column
// Path for the column if it contains a link  
"linkPath": "link-path-or-property" //<this is what the doc says
},
{
"id": "col2",
"dataPath": "name",
"label": "Name",
"width": 350,
"visible": true,
"type": "text",
"linkPath": "this is where I should have a link I think but what link"
}, {
"id": "col3",
"dataPath": "formattedPrice",
"label": "Price",
"width": 100,
"visible": true,
"type": "text",
"linkPath": "ProductPageUrl"
}, {
"id": "col4",
"dataPath": "sku",
"label": "SKU",
"width": 100,
"visible": true,
"type": "text",
} //,
// more column objects here if necessary
// ...
// ...  
];

然后我使用内置的点击事件功能:

export function table1_rowSelect(event, $w) {
//Add your code for this event here: 
console.log(event.rowData); //It does read the correct item clicked

}

这可能吗?

你正朝着正确的方向前进。是的,linkPath是您放置产品页面链接的位置。(您也可以将rowSelect事件与wixWindow.to()一起使用,但不需要同时执行这两个操作。(现在您所需要做的就是找出在linkPath中使用的正确路径。

在我看来,您的行数据使用的是Wix Stores集合。如果是这样,则在设置表列时,将使用包含链接的字段的字段键(而不是字段名(。因此,对于产品页面,请使用productPageUrl。请注意,这是每列的。因此,如果您希望每个单元格都是一个链接,则必须将linkPath添加到每列中。

最新更新