how to use renderBodyTemplate to filter state data?
Posted: 14 Sep 2020, 06:09
Hi ,
I am new to reactjs and primerecat too . I used datatable and column with renderBodyTemplate where I am filtering this.state.data but it is error with undefiend please suggest a good way to use this.state.data in renderBodyTemplate.
constructor(props) {
super(props);
this.state = {
roles:[],
roleByRoleIdTemplate(rowData){
let role = this.state.roles.filter(val => !rowData.roleId===val.id);
return <span>{role.name}</span>
}
<Column field="roleId" header="Role" body={this.roleByRoleIdTemplate}></Column>
I am new to reactjs and primerecat too . I used datatable and column with renderBodyTemplate where I am filtering this.state.data but it is error with undefiend please suggest a good way to use this.state.data in renderBodyTemplate.
constructor(props) {
super(props);
this.state = {
roles:[],
roleByRoleIdTemplate(rowData){
let role = this.state.roles.filter(val => !rowData.roleId===val.id);
return <span>{role.name}</span>
}
<Column field="roleId" header="Role" body={this.roleByRoleIdTemplate}></Column>