react with table

表格相关

<Table dataSource={data} className="mt1" columns={columns} pagination={pagination}  rowKey={record => record.city_id}/>
const columns = [{
      title: '学校名称',
      dataIndex: 'school_name',
      key: 'school_name',
      render:(text,record)=>{
        if(text!=null){
          return (<span title={text}>{text.length>15?text.substring(0,15)+'...':text}</span>)
        }
      }
    }]
var page = {
      onChange: (index) => {
        var params={
          pageIndex: index,
          pageSize: 10,
          filter: {
            city_code: this.state.cityCode,
            school_name: this.state.schoolName
        }};
        this.props.dispatch(actions.getlList(params));
      },
      total: parseInt(count),
      showTotal: (total) => {
        return `共 ${count} 条`
      },
      showQuickJumper: false,
      showSizeChanger: false,
    }

表格中的key不允许有空格,dataIndex属性为必须,确保datasource为数组形式

 

posted @ 2017-06-07 21:31  小金鱼紫苏  阅读(471)  评论(0编辑  收藏  举报