简体   繁体   中英

react material-table's search filter does not work on render

The Search works fine here :

 <MaterialTable
          columns={[
            { title: 'Name', field: 'firstname', type: 'string' }
          ]}
/>

However Search filter does not work for the below code:

<MaterialTable
          columns={[
             { title: 'Name',
               render: rowData =>{ 
                       return(<Link to = {`/${rowData.firstname}`}> 
                       {rowData.firstname} 
                       </Link>)
               },
               type: 'html'
              }
            ]}
/>
 This is the correct way to search on render. We need to add field to it.

 <MaterialTable
              columns={[
                 { title: 'Name',
                   field: 'location_name',
                   render: rowData =>{ 
                           return(<Link to = {`/${rowData.firstname}`}> 
                           {rowData.firstname} 
                           </Link>)
                   },
                   type: 'html'
                  }
                ]}
    />

就像user10665299告诉你的,需要添加field ..你可以删除type属性,不是必需的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM