I am using React+Redux along with React wrappers for the Kendo UI Grid component. Here's a crop of my code:
import React, { Component } from
'react'
import { Grid } from
'@progress/kendo-grid-react-wrapper'
;
class InputOrderComponent extends Component {
static propTypes = {
...
actionAdd: PropTypes.func,
...
}
render() {
const { inputOrder, actionSelect, listBranch, actionChange, actionAdd, actionRetrieveBranch, } =
this
.props;
return
(
.....
<Grid
dataSource={
new
kendo.data.DataSource({
transport: {
read:
function
(e){
actionRetrieveBranch()
.then(res =>{
e.success(res)
})
}
},
})}
filterable={
true
}
sortable={
true
}
groupable={
false
}
pageable={
true
}
columns={[
{title:
"No"
, filterable:
false
, template:
'#='
+ ++record +
'#'
, width:44},
{field:
"branchCode"
, title:
"Part Number"
},
{field:
"branchDescription"
, title:
"Part Description"
},
{field:
"phone1"
, title:
"HET"
, width:100},
{field:
"branchCode"
, title:
"Action"
, width:120, template:
"<button onClick=\"actionAdd.bind(this,'branchCode')\" type='button' class='k-button k-button-icontext'><i class='fa fa-plus-circle' style='margin-right: 5px'></i> Pilih</button>"
},
]}
dataBinding={
function
() {
//this.setState({
//record : (this.dataSource.page() -1) * this.dataSource.pageSize()
//})
console.log(
this
.dataSource.data())
}
}
/>
....
)
}
}
I'm having diffucilties having my onClick action recognized. While the onClick event does trigger, the actionAddaction isn't. It throws a "Uncaught ReferenceError: actionAdd is not defined
at HTMLButtonElement.onclick (inputOrder:1)" error.
Is this related to how the documentation mentions that react components are not supported in templates? I'm also having difficulties replicating this documentation on how to add Row Numbers. Records, in the template, throws an undefined error just like the above, unless I initialize the record variable outside the main component class.
Help would be appreciated.