
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
react-component-data-table
Advanced tools
$ npm i react-component-data-table --save
import {DataTable,Pagination,DataTableWithPagination} from 'react-component-data-table'
Extends PureComponent
DataTable - 数据表
Examples
Simple
class SimpleDataTableDemo extends React.PureComponent{
render(){
const dataSource=[
{name:"name1",sex:"male"},
{name:"name2",sex:"female"}
];
const columns=[
{name:"Name",render:rowData=>rowData['name']},
{name:"Sex",render:rowData=>rowData['sex']},
];
return <DataTable columns={columns} dataSource={dataSource}></DataTable>
}
}
Empty
class EmptyDataTableDemo extends React.PureComponent{
render(){
const dataSource=[];
const columns=[
{name:"Name",render:rowData=>rowData['name']},
{name:"Sex",render:rowData=>rowData['sex']},
];
return <DataTable columns={columns} dataSource={dataSource}></DataTable>
}
}
Radio DataTable
class RadioDataTableDemo extends React.PureComponent{
render(){
const dataSource=[
{name:"name1",sex:"male"},
{name:"name2",sex:"female"}
];
const columns=[
{name:"",render:rowData=>{
return <input type="radio" value={rowData['name']} name="radio-data-table"/>
}},
{name:"Name",render:rowData=>rowData['name']},
{name:"Sex",render:rowData=>rowData['sex']},
];
return <DataTable columns={columns} dataSource={dataSource}></DataTable>
}
}
Checkbox DataTable
class CheckboxDataTableDemo extends React.PureComponent{
render(){
const dataSource=[
{name:"name1",sex:"male"},
{name:"name2",sex:"female"}
];
const columns=[
{name:"",render:rowData=>{
return <input type="checkbox" value={rowData['name']}/>
}},
{name:"Name",render:rowData=>rowData['name']},
{name:"Sex",render:rowData=>rowData['sex']},
];
return <DataTable columns={columns} dataSource={dataSource}></DataTable>
}
}
Properties
columns Array<Object>
dataSource Array? [ [] ]style Object?className String? [ data-table ] - data-table是DataTable的默认className,样式定义在/css/DataTable.css.如果要使用默认样式需要引用默认的样式文件import 'css/DataTable.css'renderDataEmpty Function? [ (definedColumn)=>(<td colSpan={definedColumn.length} style={{textAlign:"center"}}>NO DATA) ]Extends PureComponent
带分页的DataTable,由DataTable和Pagination组合的复合组件
获取DataTable全局数据索引
Parameters
localRowIndex Number 当前分页中的数据索引Returns Number 全局数据索引
...DataTable.propTypes ...Pagination.propTypes
Properties
style Object?className String?dataTableStyle Object? DataTable样式dataTableClassName String? DataTable css classpaginationStyle Object? Pagination 样式paginationClassName String? Pagination css classshowIndex Boolean? [ true ] - 是否显示索引列Extends PureComponent
Pagination - 页码
Parameters
propsExamples
从0开始分页
<Pagination
onPageChange={(pageInfo)=>{
console.log('page change',pageInfo)
}}
total={23}/>
从1开始分页
<Pagination
startPageNumber={1}
pageIndex={1}
onPageChange={(pageInfo)=>{
console.log('page change',pageInfo)
}}
total={100}/>
总页数
当前页码
每页记录数
起始分页页码
Properties
startPageNumber Number? [ 0 ] - 分页开始的起始页0或者1pageIndex Number? [ 0 ] - 当前页pageSize Number? [ 10 ] - 每页记录数onPageChange Function? [ ()=>null ] - 分页事件监听total Number 总记录数style Object? 样式className String [ pagination ] - css class样式,样式定义在css/Pagination.cssdisplayPageCount Number? [ 5 ] - 最多可以显示多少页面renderNextPage Function? [ ()=>(">") ] - >按钮样式renderPrevPage Function? [ ()=>("<") ] - <按钮样式FAQs
<!-- badge -->
The npm package react-component-data-table receives a total of 3 weekly downloads. As such, react-component-data-table popularity was classified as not popular.
We found that react-component-data-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.