react把表格渲染好ui_使用reactjs渲染表格

Hi Im starting with the reactjs. After working with the basics in react, Im trying to work on the reactjs with dynamoDB. First query Im working on is Select query, and render the table in html file. So right now Im able to get the json array from desired table using select query. But Im not able display the rendered data in a table format i.e I get a json array like below and able to display data 4281, taniv, secondary... but not able to display the header for each value (id, name, class, etc.), so how to display the header for each json value. I want it to be dynamic because I want to show what is in the db(if some of the attributes are not there or missing I don't want it to be displayed) :

[

{

"id": 4281,

"name": "taniv",

"class": "secondary",

"admission": 227,

"telephone": "209-109-2322",

"address": "11 first lane",

"postCode": "5788009",

"county": "UK",

}]

js

Result

{data.map((obj, y) => {

return Object.keys(obj).map((x, y) =>

{obj[x]} )

})}

解决方案

I made an example on codesandbox.io for you (:

From what I understood you are trying to make your table completely dynamic. You essentially want keys in your object to be table headers and corresponding values to be table row data. Please checkout the example and let me know if this helps or if you have any questions you can find me on Twitter (@jonmajorc). Good luck!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值