Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 物料表中的粘性头_Javascript_Reactjs_Material Table - Fatal编程技术网

Javascript 物料表中的粘性头

Javascript 物料表中的粘性头,javascript,reactjs,material-table,Javascript,Reactjs,Material Table,我在看这个例子,我的问题是一个粘性标题。例如: 我试图弄清楚,看看我是否可以得到标题的名字到出生地是坚持,所以当我创建滚动条,它将留在那里。我什么都试过了,但结果总是不一样。任何帮助都会很好 class BasicFixedColumns extends React.Component { constructor(props) { super(props); this.state = { } } render() { return (

我在看这个例子,我的问题是一个粘性标题。例如:

我试图弄清楚,看看我是否可以得到标题的名字到出生地是坚持,所以当我创建滚动条,它将留在那里。我什么都试过了,但结果总是不一样。任何帮助都会很好

class BasicFixedColumns extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
    }
  }

  render() {
    return (
      <MaterialTable
        title="Basic Fixed Columns Preview"
        columns={[
          { title: 'Name', field: 'name', width: 150 },
          { title: 'Surname', field: 'surname', width: 150 },
          { title: 'Birth Year', field: 'birthYear', type: 'numeric', width: 150 },
          {
            title: 'Birth Place',
            field: 'birthCity',
            lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
            width: 150
          },
          { title: 'Name', field: 'name', width: 150 },
          { title: 'Surname', field: 'surname', width: 150 },
          { title: 'Birth Year', field: 'birthYear', type: 'numeric', width: 150 },
          {
            title: 'Birth Place',
            field: 'birthCity',
            lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
            width: 150
          },
        ]}
        data={[
          { name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
          { name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
        ]}        
        options={{
          fixedColumns: {
            left: 2,
            right: 1
          }
        }}
      />
    )
  }
}
类BasicFixedColumns扩展React.Component{
建造师(道具){
超级(道具);
此.state={
}
}
render(){
返回(
)
}
}

您需要设置
maxBodyHeight
属性。然后,当数据超过此高度时,表格将可滚动并带有粘性标题

<MaterialTable
    options={{
        paging: false,
        maxBodyHeight: '300px',
    }}
    columns={columns}
    data={data}
/>

它给了你什么?你能创建一个沙盒吗?在网站上,如果你向下滚动到示例,就会看到显示代码,它可以作为ide使用。这是一个被称为基本固定列的例子,在这个例子的右边有一个,你可以点击它,你可以从那里编辑代码,它会呈现你所做的任何改变,我知道,但是你到底想实现什么。啊,我想为第一行实现一个粘贴标题啊,好的,因为链接是一个粘贴列而不是行。目前不支持此问题。对于访问此问题的用户,您可以检查此问题
columns[0].cellStyle = {
    backgroundColor: '#007eff',
    color: '#FFF',
    position: 'sticky',
    left: 0
}