Advertisement
Misipuk

home_old3

Jul 20th, 2021
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import wixData from 'wix-data';
  2. import wixFetch from 'wix-fetch';
  3.  
  4. $w.onReady(function () {
  5.     //load_hv_table()
  6.     load_opt_price()
  7. });
  8.  
  9.  
  10. async function load_hv_table() {
  11.     const res = await wixData.query('hv_data').find();
  12.     //var json = JSON.parse(res.items[0]["jsondata"])
  13.     console.log(res.items)
  14.     var json = JSON.parse(res.items[0]["jsondata"])
  15.     console.log(json)
  16.     //console.log(Object.keys(json[0]))
  17.     //await wixData.insert("temp", json[0])
  18.  
  19.     var cols = []
  20.     Object.keys(json[0]).forEach(key => {
  21.         if (key[0] != "_")
  22.             cols.push({
  23.                 "id": key.toString(),
  24.                 "label": key.toString(),
  25.                 "dataPath": key.toString(),
  26.                 // "width": 100,
  27.                 // "visible": true,
  28.                 // "type": "string"
  29.             })
  30.     })
  31.  
  32.    
  33.     console.log(cols)
  34.     $w("#table1").columns = cols;
  35.     //console.log($w("#table1").columns);
  36.     $w('#table1').rows = json;
  37. }
  38.  
  39. async function load_opt_price() {
  40.     const res = await wixData.query('opt_data').ascending("title").find();
  41.     var json = JSON.parse(res.items[0]["call1"])
  42.     console.log(json)
  43.     console.log(Object.keys(json[0]))
  44.     //await wixData.insert("temp", json[0])
  45.  
  46.     let cols = []
  47.     Object.keys(json[0]).forEach(key => {
  48.         if (key[0] != "_")
  49.             cols.push({
  50.                 "id": key.toString(),
  51.                 "label": key.toString(),
  52.                 "dataPath": key.toString(),
  53.             })
  54.     })
  55.     $w("#table1").columns = cols;
  56.     //console.log($w("#table1").columns);
  57.     $w('#table1').rows = json;
  58. }
  59.  
  60.  
  61. async function loadData() {
  62.     const res = await wixData.query('Data').limit(200).find();
  63.     const data = res.items;
  64.     //$w('#table2').rows = data;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement