I'm very new at this and have a dataset that contains some number values. The dataset is linked to a Table output using code following a query. I want some of the numbers to format as currency in the table, at the moment they appear just as they are in the dataset. The 'query code' is below:
wixData.query("ProductDetail")
.ascending("priceGbUs")
.contains("coverage",$w("#input3").value)
.find()
.then(res => {
if(wixWindow.formFactor === "Desktop"){
$w("#table1").rows = res.items;
$w("#table1").expand();
}
if(wixWindow.formFactor === "Mobile"){
$w("#table4").rows = res.items;
$w("#table4").expand();
}
});
The table columns are set up in the typical way as below:
$w("#table1").columns = [{
"id":"col1",
"dataPath": "title",
"label": "Provider",
"type": "string",
"width": 120,
}, {
"id": "col2",
"dataPath": "link",
"label": "Link",
"type": 'string',
"width": 220,
"visible": false,
}, {
"id": "col2",
"dataPath": "additionalInfo1",
"label": "Additional Info 1",
"type": 'string',
"width": 220,
"visible": false,
}, {
"id": "col2",
"dataPath": "image",
"label": "Image",
"type": 'image',
"width": 220,
"visible": false,
}, {
"id": "col2",
"dataPath": "buyLink",
"label": "Buy Link",
"type": 'string',
"width": 220,
"visible": false,
}, {
"id": "col3",
"dataPath": "planName",
"label": "Plan Name",
"type": "string",
"width": 220,
}, {
"id": "col4",
"dataPath": "dataGb",
"label": "Data (GB)",
"type": "number",
"width": 130,
}, {
"id": "col5",
'dataPath': 'validityDays',
'label': 'Validity (Days)',
'type': 'number',
"width": 130,
}, {
'id': 'col6',
'dataPath': 'priceUs',
'label': 'Price ($US)',
'type': 'number',
"width": 130,
}, {
'id': 'col6',
'dataPath': 'priceGbUs',
'label': 'Price/GB ($US)',
'type': 'number',
"width": 150,
}]
Would appreciate any assistance.
Hello!
Take a look at this forum post that might be helpful:
https://www.wix.com/corvid/forum/community-discussion/dynamically-format-numerical-user-input-as-currency
And also there is always a lot of questions regarding formatting (date/currency/time etc), check out forum for helpful posts, a lot of people asked the same question and a lot of code snippets are shared over the time:
https://www.wix.com/corvid/forum/search/format-as-currency
Good luck!