npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tntx/nested-table

v1.0.11

Published

基于ant3开发的嵌套表格,用于弥补<Table>@ant3中 expandedRowRender={return <Table>} 时无法同时使用Column.fixed='right'的问题。参考官方提示(Warning: [antd: Table] `expandedRowRender` and `Column.fixed` are not compatible. Please use one of them at one time.)

Downloads

15

Readme

Nested Table 嵌套表格

基于Ant3开发的嵌套表格,用于弥补<Table>expandedRowRender = { return <Table> } 时无法同时使用Column.fixed='right'的缺陷。

缺陷表现为表格整列消失、样式错乱等,参见官方提示:

(Warning: [antd: Table] `expandedRowRender` and `Column.fixed` are not compatible. Please use one of them at one time.)",

安装、发布与源码

安装:npm i @tntx/nested-table
发布:https://www.npmjs.com/package/@tntx/nested-table
源码:https://github.com/YuDGang/nested-table-react/tree/master/src/components/NestedTable

更新日志

  • 1.0.11 样式小改;
  • 1.0.9 删除部分依赖;
  • 1.0.8 修复了在同页面有两个及以上 NestedTable 且来回切换时宽度值互相干扰的问题;
  • 1.0.7 提升了兼容性;
  • 1.0.6 更名参数 insertFromRecord 为 insertFromParent ;
  • 1.0.4 性能优化;
    ...

API

支持所有 Ant3 Table 参数 ,仅expandedRowRender 不可用,其余参数正常。 以下为新增参数 | 参数 | 说明 | 类型 | | ---- | ---- | ---- | | expandRows | 内表格的配置描述,具体项见下表 | Object |

expandRows

| 参数 | 说明 | 类型 | | ---- | ---- | ---- | | dataSourceIndex | 内表格的数据源索引 | string | | columns | 为内表格配置其columns | columnsType[] | | rowKey | 为内表格指定其rowKey | string | | withoutHead | 去除内表格的第一行数据,常用于内表格数据源的第一条与外表格当前行数据重复时 | boolean | | ~~insertFromRecord~~| ~~已更改为insertFromParent~~ | ~~insertIndex["index0","index1"...]~~ | | insertFromParent| 从点击行的record中获取并插入数据至展开行的record,并可以用record.parentProp访问,常用于内表格数据中缺少某些需要使用的当前行数据时 | insertIndex["index0","index1"...] |

何时使用

当需要指定表格的展开行仍为表格,且需要最右侧列固定时。

如何使用

  • 数据源:将内表格数据源dataSourceIndex指定为外表格数据源dataSource中的相应索引;
  • 对 齐:为外表格和内表格分别指定其 columns ,为需要对齐的列指定相同宽度; 若需要跨行或空行,将宽度转加在其他列
  • 固 定:同时为外表格和内表格的最右侧列配置 Columns.fixed: "right", 并在外表格指定 scroll

代码演示

import NestedTable from "@tntx/nested-table";

const dataSource = [
	{
		"id": "000",
		"parentVersion": "1",
		"parentName": "标尺0",
		"innerList": [
			{
				"id": "000-0",
				"createUser": "admin"
			}, {
				"id": "000-1",
				"createUser": "admin"
			}, {
				"id": "000-2",
				"createUser": "admin"
			}
		]
	}, {
		"id": "001",
		"parentVersion": "1",
		"parentName": "标尺1",
		"innerList": [
			{
				"id": "001-0",
				"createUser": "admin"
			}
		]
	}
];

const columns = [
	{
		title: "标识",
		width: "300px",
		dataIndex: "id"
	}, {
		title: "版本",
		width: "300px",
		dataIndex: "parentVersion"
	}, {
		title: "名称",
		width: "300px",
		dataIndex: "parentName"
	}, {
		title: "操作",
		width: "200px",
		fixed: "right"
	}
];

const columnsInner = [
	{
		width: "300px",
		dataIndex: "id"
	}, {
		width: "300px"	// 空列给予宽度占位,以保证对齐
	}, {
		width: "300px",
		render: record => <>{record.parentProp.parentName}</>
	}, {
		title: "操作",
		width: "200px",
		fixed: "right",
		render: record => <a>操作</a>
	}
];

const expandRows = {
	rowKey: "id",
	columns: columnsInner,
	dataSourceIndex: "innerList",
	withoutHead: true,
	insertFromParent: ["parentName", "parentVersion"]
};

export default () => {
	return (
		<NestedTable
			rowKey="id"
			columns={columns}
			dataSource={dataSource}
			expandRows={expandRows}
			scroll={{"x": "1100"}}
		/>
	);
};