Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateHTMLTable方法生成的html是否可以对每个单元格加id等其他属性? #33

Open
youngshop opened this issue Jan 9, 2022 · 4 comments

Comments

@youngshop
Copy link

generateHTMLTable(data, schema, options)。
虽然有attributes可选属性,加入的是公共的属性控制,是否可以扩展一下到每个单元格也可以定制一个id,这样方便控制生成的表格,从而进行更加个性化的展示。
谢谢

@yetrun
Copy link
Owner

yetrun commented Jan 10, 2022

目前还不可以,需要扩展。现在的接口是

generateHTMLTable(data, schema, options)

如果让每个单元格都可以定制一个属性,我还不知道怎么定义。是在数据中定义吗?像这样:

data = [
  {
    id: { data: 1, attrs: 'id=1' },
    name: { data: 'Jim', attrs: 'style="color: red"' },
    age: { data: 18, attrs: 'style="color: blue"' }
  },
  {
    id: { data: 2, attrs: 'id=2' },
    name: { data: 'James', attrs: 'style="color: pink"' },
    age: { data: 28, attrs: 'style="color: yellow"' },
  }
]

@youngshop
Copy link
Author

对,按照你说的这样就很灵活了,我觉得这样会非常棒。

@yetrun
Copy link
Owner

yetrun commented Jan 13, 2022

我想了一下,不太可行,这样完全改变了以前的调用方式,不兼容之前的数据了。

本来我的调用是:

generateHTMLTable([
  { id: 1, name: 'Jim', age: 18 },
  { id: 2, name: 'James', age: 28 },
])

面向的是普通的 JavaScript 数组或对象。修改后就没有这个特点了,之前用这个仓库的小伙伴的调用方式都得调整,而且不太通用。

@robross0606
Copy link

robross0606 commented Jun 16, 2022

What about adding an option to the schema so you can specify data properties that represent cell attributes instead of its data? If not specified, the function work the same as it did previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants