Hi,
I'm building a React Web App for dental clinics.
Instead of react class component I'm using function with React Hooks, useState, useEffect.
I'm using GridComponent (@syncfusion/[email protected]) in order to manage clinics, users, patients..
I have a set of function called "cicassservice" that use axios promise func to get, update, delete items.
Everything worked fine, but I needed to use a custom datetimepicker for the birthday date of patients.
So in the relative columndirective I used the parameter editTemplate in this way:
<ColumnDirective field='birthday' editTemplate={(e) => calBirth()} format={'dd/MM/yyyy'} type='date' headerText={props.t('Data Nascita')} />
where calBirth is
const calBirth = (args) => { //console.log(args);
return (<DatePickerComponent value={getValue('birthday', args)} id="birthday" placeholder="To" floatLabelType='Always' format='dd/MM/yyyy' />)
}
The datepickercomponent is correctly shown, I can choose dates, but when I try to save after a new item insert, I get a white screen with a generic GridComponent error.
I think is something between editTemplate and React Hooks because of I had another app, and with react class component is working correctly.
Can you help me?
In the zip attached you can find the error, the syncfusion packages installed, the file patient.js with the whole function and the images of the app.
Thank you in advance.
Alex
|
const editTemplate =(args)=> {
return (<DatePickerComponent value={getValue('OrderDate', args)} id="OrderDate" placeholder="Order Date" floatLabelType='Never'/>)
}
var grid;
var initialFlag = true;
var toolbarOptions = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
var filterSettings = { type: 'Menu' }
var startDate = '';
var endDate = '';
var customFilter = false;
const SyncGrid = () =>{
return (
<div>
<GridComponent
id={"Grid"}
dataSource = {hierarchyOrderdata.slice(0,9)}
allowFiltering={true}
filterSettings={filterSettings}
ref={g => (grid = g)}
toolbar={toolbarOptions}
editSettings={editOptions}
height={320}
>
<ColumnsDirective>
<ColumnDirective
field="OrderID"
headerText="Order ID"
width="100"
isPrimaryKey ={true}
/>
<ColumnDirective
field="CustomerID"
headerText="Customer ID"
width="100"
/>
<ColumnDirective
field="OrderDate"
headerText="Order Date"
type='date'
format='dd/MM/yyyy'
editTemplate={editTemplate}
width="100"
/>
<ColumnDirective
field="ShipCountry"
headerText="Ship Country"
width="100"
/>
</ColumnsDirective>
<Inject services={[Toolbar, Edit, Page, Filter]} />
</GridComponent>
</div>
);
}
|
Hi Rajapandi,
I found the origin of the issue: in component-base.js of ej2-react-base module, at row 347 there's a for cycle with a wrong length array: it's used allColumns.length instead of changedProps.length.
if (this.getModuleName() === 'grid' && key === 'columns') {
for (var _c1 = 0, allColumns = this.columns; _c1 < allColumns.length; _c1++) {
var compareField1 = getValue('field', allColumns[_c1]);
var compareField2 = getValue(_c1 + '.value.field', changedProps);
if (compareField1 === compareField2) {
var propInstance = getValue(changedProps[_c1].key + '.' + changedProps[_c1].index, this);
if (propInstance && propInstance.setProperties) {
propInstance.setProperties(changedProps[_c1].value);
}
else {
extend(propInstance, changedProps[_c1].value);
}
}
}
}
My allcolumns contain a one more item, "Actions". This call an exception.
I controlled the same file in old version: there was changedProps.length correctly.
Please correct it.
I send you the correct component-base file
Best regards
Alex