Greetings!
I was working on a datatable with editing of one of the columns, and have some problems with the demo example code.
Firstly, it has some bad paths in the import statements - not a huge problem, but suggests that the example code is different to the running example.
Secondly, the example shows two different ways to pass member functions down into the datatable:
type 1:
saleDateEditor(props) {
return (
<Calendar value={this.state.cars[props.rowIndex].saleDate}
onChange={(e) => this.onEditorValueChange(props, e.value)} style={{width:'100%'}} />
);
}
and type 2:
<Column field="saleDate" header="Sale Date" editor={this.saleDateEditor}
If I use the type 2, when I debug the saleDateEditor function, it says that "this" is a class, but not the class I am working on, just class - and as a result this.state.XXX is not found. When I changed my code to be like type 1, eg:
<Column field="Description" header="Question text" editor={(p) =>this.descEditor(p)}/>
it works fine!
I am a React newby so I don't want to describe what the difference is, but the examples should be fixed please.
Thanks
Ross
(couple years PrimeFaces user)
Datatable edit example problem
Ross,
You should be able to make that a fat arrow function and this would become valid.
But ya, probably good for a doc update. I too encountered the bad import statements. I don't suppose this is open sourced to where we could fork and make the fixes ourselves.
You should be able to make that a fat arrow function and this would become valid.
Code: Select all
saleDateEditor = (props) => {
return (
<Calendar value={this.state.cars[props.rowIndex].saleDate}
onChange={(e) => this.onEditorValueChange(props, e.value)} style={{width:'100%'}} />
);
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests