The error I have is once my table loads data from code, the headers become misaligned:
Before the data is loaded into the table columns are lined up properly:
But once the table data is loaded from code the columns no longer are equally spaced. For example the “Type” column is way too close to the “Ticker” column
Code to set table data:
async function setTable(tickerList,exp, moic) {
var myTableData = [{"Ticker":"","expiration":"","outMoney":"","volume":"","min cost":"", "moic":"","new_col":"","new_col2":""}]
$w("#table10").rows = myTableData
let formFactor = wixWindow.formFactor;
richTable(formFactor)
var oPrices = await getOptPrices(tickerList, selectedExpiration, selectedMOICNew);
oPrices.sort((a, b) => (a["MOIC"] < b["MOIC"]) ? 1 : -1)
var test1 = []
if (formFactor == 'Desktop') {
for (let i = 0; i < 50; i++) {
test1.push({"Ticker":hiddenTicks[i],
"moic":"$" + numberWithCommas(oPrices[i]["minCost"].toFixed(0)),
"expiration":opTypeDis,
"outMoney":getDate(oPrices[i]["expirDate"]),
"volume":oPrices[i]["strike"],
"min_cost":((outMoney - 1.0)*100.0).toFixed(2) + "%",
"new_col":(oPrices[i]["chanceProfit"]*100.0).toFixed(1) +"%",
"new_col2":setGreenRed((globalData[i]["percentReturn"]*100.0)),
});
}
}
$w("#table10").rows = test1
$w("#table10").refresh()
}
Code to set table columns: (I have tried manually setting the width to 100 for each but this did not fix the issue)
if (typeW == 'Desktop') {
$w("#table10").columns = [
{
"id": "column_khr6ndb3",
"dataPath": "Ticker",
"label": "Ticker",
"type": "richText",
},
{
"id": "column_khr6nyv4",
"dataPath": "expiration",
"label": "Type",
"type": "string",
},
{
"id": "column_khr6ow7v",
"dataPath": "outMoney",
"label": "Expiration",
"type": "string",
},
{
"id": "column_khr5wyo7",
"dataPath": "volume",
"label": "Strike",
"type": "string",
},
{
"id": "column_khr5wtak",
"dataPath": "min_cost",
"label": "Break Even",
"type": "string",
},
{
"id": "column_khr6oa5k",
"dataPath": "moic",
"label": "Min Cost",
"type": "richText",
},
{
"id": "column_khr6oa5k",
"dataPath": "new_col",
"label": "Chance of Profit",
"type": "richText"
},
{
"id": "column_ko67juei",
"dataPath": "new_col2",
"label": "Projected Return",
"type": "richText"
}
];
}