Code Monkey home page Code Monkey logo

table's People

Contributors

afc163 avatar alexkvak avatar benjycui avatar cheton avatar crazyair avatar ddcat1115 avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar hackape avatar jaredleechn avatar jljsj33 avatar kiner-tang avatar li-jia-nan avatar linxianxi avatar madccc avatar nokecy avatar paranoidjk avatar queimadus avatar shaodahong avatar wuguanghai45 avatar xrkffgg avatar yesmeck avatar yiminghe avatar yoyo837 avatar ystarlongzi avatar yuyangvi avatar yykoypj avatar zhujun24 avatar zombiej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

table's Issues

Manage expanded rows externally

As the library stands there is no way to control the expanded rows pragmatically (closing the expanded rows externally e.g.).

Do you plan on adding functionalities to allow this or do you rather keep this as internal state to keep the library simple?

Support max-height when setting the scroll={{ y:300 }}

When the scroll={{y:300}} is set to the table, and somehow the data is not enough to fullfill it, the height will keep being 300px, with the remaining space in blank empty.

The style height:300 is added to table body when the scroll set, and it's fixed. How about we make it to max-height:300 so it's flexible to support the situation when the data is less than the value?

I made a codePen demo here, you may check the link if it helps, thanks!

grouping columns problem

const columns = [
    {
        title: '其它',
        children: [
            {
                title: '年龄',
                dataIndex: 'age',
                key: 'age',
            },
            {
                title: '住址',
                children: [
                    {
                        title: '街道',
                        dataIndex: 'street',
                        key: 'street',
                    },
                    {
                        title: '小区',
                        children: [
                            {
                                title: '单元',
                                dataIndex: 'building',
                                key: 'building',
                            },
                            {
                                title: '门牌',
                                dataIndex: 'number',
                                key: 'number',
                            },
                        ],
                    },
                ],
            },
        ],
    },
    {
        title: '公司',
        children: [
            {
                title: '地址',
                dataIndex: 'companyAddress',
                key: 'companyAddress',
            },
            {
                title: '名称',
                dataIndex: 'companyName',
                key: 'companyName',
                children: [
                    {
                        title: 'FirstName',
                        dataIndex: 'firstName',
                        key: 'firstName'
                    },
                    {
                        title: 'LastName',
                        dataIndex: 'lastName',
                        key: 'lastName'
                    }
                ]
            },
        ],
    }
];

const columns2 = [
    {
        title: '其它',
        children: [
            {
                title: '年龄',
                dataIndex: 'age',
                key: 'age',
            },
            {
                title: '住址',
                //children: [
                //    {
                //        title: '街道',
                //        dataIndex: 'street',
                //        key: 'street',
                //    },
                //    {
                //        title: '小区',
                //        children: [
                //            {
                //                title: '单元',
                //                dataIndex: 'building',
                //                key: 'building',
                //            },
                //            {
                //                title: '门牌',
                //                dataIndex: 'number',
                //                key: 'number',
                //            },
                //        ],
                //    },
                //],
            },
        ],
    },
    {
        title: '公司',
        children: [
            {
                title: '地址',
                dataIndex: 'companyAddress',
                key: 'companyAddress',
            },
            {
                title: '名称',
                dataIndex: 'companyName',
                key: 'companyName',
                children: [
                    {
                        title: 'FirstName',
                        dataIndex: 'firstName',
                        key: 'firstName'
                    },
                    {
                        title: 'LastName',
                        dataIndex: 'lastName',
                        key: 'lastName'
                    }
                ]
            },
        ],
    },
];

First columns is good, but second is wrong.

Access nested properties with dataIndex

Have you considered using something like https://github.com/mariocasciaro/object-path to parse dataIndex?

const data = [{
  name: "John", 
  age: 25 , 
  custom: {
    one: 1, 
    two: 2
  }
}]

const columns = [{
  title: "Name",
  dataIndex: "name"
}, {
  title: "Age",
  dataIndex: "age"
}, {
  title: "My custom property one",
  dataIndex: "custom.one"
}, {
  title: "My custom property two",
  dataIndex: "custom.two"
}]
Name Age My custom property one My custom property two
John 25 1 2

support sorting by multiple columns?

suppose we have three columns:

Country City Name
China Shanghai Zhang San
USA New York Jack
China Beijing Li Si
USA LA Rose
China Shanghai Wang Wu

sort it by "Country", and then "City", "Name", after the sort, the table becomes:

Country City Name
China Beijing Li Si
China Shanghai Wang Wu
China Shanghai Zhang San
USA LA Rose
USA New York Jack

有没有必要对表格的TableRow性能优化?

有没有必要在TableRow中使用shallowequal或者immutable.js的is方法来优化表格的性能呢?
比如:

const TableRow = React.createClass({
  ...
  shouldComponentUpdate(nextProps, nextState) {
    return !shallowequal(nextProps, this.props) || !shallowequal(nextState, this.state);
  },

}

如果一个页面的表格有成百上千行,任何一个state或者props改变都会触发每个TableRow的render,这个对整个页面的性能损失是很大的。
所以,有没有必要也对TableRow添加shouldComponentUpdate方法?

数据变化导致 columns 定义的 render 不会重新执行

使用时发现, 我改变了数据状态 引起 render 渲染 但是在 columns 字段里定义的 render 是不会重新执行的 使用如果要在 table 里实时反应出来 columns 字段必须定义在 render 方法里面 这个问题不知道 不知道大神是怎么解决的
image

但是写在 render 函数里就 OK 了

paging columns table bug

我用了一下 paging columns
方法 getMaxColumnsPage 有些问题
发现当 columnsPageSize=2 columnsPageRange= [2, 4]

Math.floor((columnsPageRange[1] - columnsPageRange[0] - 1) / columnsPageSize); // 结果为0

第三列无法显示

我试着更正了一下

Math.floor((columnsPageRange[1] - columnsPageRange[0] + 1) / columnsPageSize)

Drag and drop support

Is it possible to support drag and drop? I am searching for tree where i can drag a row and drop a row.

请问下是否支持/兼容redux或者其他数据流呢?

因为用redux数据流的话,action reducer等是分开的,并且是只维护一套state即store,但是如果
我的管理系统用到这个组件的话(基于redux数据流),我如何整合到我的管理系统里面呢?看了你们官方的antd table 模式跟我们很类型,想请问您们在做这些项目的时候是如何去管理数据流的呢?

固定行

  • 固定行
    表格上下固定行
    例:
    上: 提示行
    下: 汇总行

does the component support column sorting?

It's not clear from the documentation or examples.

I thought there would be a 'onColumnHeaderClick' method or something to hook up some sort logic but doesn't seem to be.

Any pointers or suggestions appreciated.

Expose click event in onRowClick

Currently onRowClick expose Function(record, index), but there should be original click event as third parameter Function(record, index, event).

Example use case is filtering row clicks based on click target.

I can PR this if you agree with this behaviour.

表头行合并(Grouping columns)

现在表头已经可以列合并了,不知道有没有考虑过行合并?

我大概看了下代码,感觉按现在的 API 设计通过 rowspan 去做合并会比较难实现,是不是可以参考ag-grid的设计,比如要实现下面这样的表头合并:

姓名 其它
年龄 住址

可以写成这样:

const columns = [{
  title: '姓名',
  dataIndex: 'name',
}, {
  title: '其它',
  children: [
    {
      title: '年龄',
      dataIndex: 'age',
    }, {
      title: '住址',
      dataIndex: 'address',
    }
  ]
}];

onRowDbClick

希望table组件可以处理 行的双击事件onRowDbClick

I hope rc-table can deal with 'onRowDbClick' event.

table的key的问题

https://github.com/react-component/table/blob/master/src/Table.jsx#L55

这里key等于数组的index,如果原来数组中某个元素删除了的时候,就会出现bug。

比如

'use strict';

var React = require('react');
var Table = require('rc-table');

var CheckBox = React.createClass({

  render: function() {
    return (
      <label>
        <input type="checkbox" />
        {this.props.id}
      </label>
    );
  }
});

var MyTable = React.createClass({

  getInitialState: function() {
    return {
      data: this.props.data
    };
  },

  handleClick: function(index) {
    var self = this;
    return function() {
      self.remove(index);
    };
  },

  remove: function(index) {
    var rows = this.state.data;
    rows.splice(index, 1);
    this.setState({
      data: rows
    });
  },

  renderAction: function(o, row, index) {
    return <a href="#" onClick={this.handleClick(index)}>删除</a>;
  },

  render: function() {
    var state = this.state;
    var columns = [
      { title: '表头1', dataIndex: 'a', width: 100, renderer: this.checkbox },
      { title: '表头2', dataIndex: 'b', width: 100},
      { title: '表头3', dataIndex: 'c', width: 200},
      { title: '操作', dataIndex: '', renderer: this.renderAction }
    ];
    return (
      <Table columns={columns} data={state.data} className="table"/>
    );
  },

  checkbox: function(a) {
    return <CheckBox id={a} />;
  }
});

var data = [{a: '123'}, {a: 'cdd', b: 'edd'}, {a: '1333', c: 'eee', d: 2}];

React.render(
  <div>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
    <MyTable data={data} className="table"/>
  </div>,
  document.getElementById('__react-content')
);

这个代码,丢example里,表头1这一列选中checkbox,这时候,把当前这一列删除。

下面一条占据了被删除那一列的位置,这时候key没有改变,CheckBox组件是不会更新。所以下面一列checkbox还是选中状态。

how to make cell editable...

Hi , i am using this component in my react project. i want to know how to make cells editable on double click etc. i should be able to double click modify cell value and save it.

Expand all row initially not working

I saw one example for expand and collapse but it works only after render if I am not wrong ( expandedRowKeys={[0,1,2]} )

Actually I want to show all row expanded initially so I tried expandedRowKeys={[0,1,2]} props but it wan't worked.

Then I also tried defaultExpandAllRows={true} but that also not worked.

Async getter

I can't get it to work when I'm loading data from the backend, on the Tree mode.

I click on a plus sign for an item that has no children, then use onExpand to fetch the children for that record from the server, but by the time the api call returns, the render has completed, so it shows a minus sign with no children.

How can this be improved ?

Issue integrating with spring-rest response

Hi i was trying to make use subTable example and consume data from spring -rest. my service returns the data in this format.

i followed this example:
https://spring.io/guides/tutorials/react-and-spring-data-rest/

to create a rest data provider and inject its response into rc-table via Axios call.

rest response contains _embedded, _links and i guess rc-table component explicitly looks for "children"
sub element array to render subTable.

how can i translate incoming json response to fit into the world of sub-table example.

怎样控制某列的显示与隐藏

现在业务场景有这样的需求,需要通过权限控制某些列的显示隐藏,请问有没有类似的实现方式?
比如在columns下添加hidden配置项等。

onRowClick 精确点击

目前的 onRowClick 粒度控制在整行,但是无法精确到具体的 column 以及 expandIcon 这些更小力度上(需要用户自己根据 SyntheticMouseEvent 来判断

业务场景是,类似 加载树形结构数据 这种,但需要在点击 expandIcon 是加载自己的 children 元素

有无必要给 onRowClick 增加一个参数,来描述具体点击到的 column ?

初步想法是分析 SyntheticMouseEvent.target.attributes 的 react-id 来确定 column,再根据 rc-table 设置的 key 来确定是否是 expandIcon 这些更深层次的 target

@afc163 @benjycui

Is UMD build is also available

i am in middle of trying this out . is there any umd build available so that i can directly import it inside <script> tag and make use of it.

Provide a function onRowHover

  1. When mouse hover a row, I want to render a few buttons(edit/delete) to append to a row cell.

It can be implemented like below.

Change two functions of the file 'TableRow.jsx'

onMouseEnter(event) {
const { onHover, hoverKey, record, index, onRowHover } = this.props;
onHover(true, hoverKey); //it's a inner function
onRowHover(record, index, event);
},

onMouseLeave(event) {
const { onHover, hoverKey, onRowHover } = this.props;
onHover(false, hoverKey);
onRowHover(null, null, event);
},

Feature Proposal: Animate expanding/collapsing of rows

Right now, rows are expanded/collapsed by toggling display: none via javascript. the display-property can't be animated unfortunately.

a quick win would be to apply css-classes expanded & collapsed instead of setting it via javascript. this way users could add animations themselves by simply overwriting the display: none css with an animation of their choice (e.g. animating the height from 0 to 100% or using some sort of transform)

table 的 columns 的 width 属性某些情况下不起作用?

如果单元格里面的内容是一个很长的英文字符串,中间没有空格等,这个字符串长度超过了 cloumns的定义的width 宽度,表格的列宽度就无法起作用。
后面我在样式中增加了 word-wrap:break-word; 就可以了。

Data updated from outside are not updated

If I update value of some key inside data array, relevant data cell isn't updated with new value.

When I commented out shouldComponentUpdate inside TableCell.jsx everything works just fine.

Nested Rows support ?

i am trying to check if component has support for nested rows or has concept of row grouping.
for example i have descriptor row and its value is some of its child rows:

Light Motor Vehicles ----- 9
(-) Car ---- 2
(-) motorcycles --- 3
(-) Add new Row --- 4

similar to what we can do in Excel ?.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.