Ejs-grid Child Grid DropDown Not Update to the JSON Array

Hello Syncfusion team, 

ej2-angular-grids version  ^19.2.49

Hierarchical Child Grid DropDown Not Update to the JSON Array. When changing the child grid dropdown value it is not updated to the JSON Array. I want to know how to get the LAST Edited grid['currentViewData'].

Parents Grid Policy DropDown change Data correctly updated to the JSON Array. But Child Grid change data is not updated.

Can you please help with this ASAP?


OUTPUT ARRAY



CODE :

<ejs-grid
#grid2
[(dataSource)]="containerdata"
[childGrid]="childGrid"
[editSettings]="editSettings"
[toolbar]="toolbar"
>
<e-columns>
<e-column
field="section"
headerText="Section"
[allowEditing]="false"
>e-column>
<e-column
field="plant"
headerText="Plant Code"
[allowEditing]="false"
>e-column>
<e-column
field="policy"
headerText="Policy"
[validationRules]="policyRules"
editType="dropdownedit"
[edit]="stateParams"
>e-column>
e-columns>
ejs-grid>

child_grid() {
//console.log(data[0]);
this.childGrid = {
dataSource: this.lineDatas,
queryString: 'section',

editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: 'Normal',
newRowPosition: 'Bottom',
},
pageSettings: { pageSize: 6, pageCount: 5 },
toolbar: ['Update', 'Cancel'],
columns: [
{
field: 'workCenter',
headerText: this.translateService.instant('pics.workcenter'),
textAlign: 'Left',
allowEditing: false,
//width: 400,
},
{
field: 'policy',
headerText: this.translateService.instant('pics.Policy'),
textAlign: 'Left',
editType: 'dropdownedit',
edit: {
params: {
allowFiltering: true,
dataSource: new DataManager(this.state),
fields: { text: 'dispaly_code', value: 'dispaly_code' },
change: (data: any) => {
},
query: new Query(),
actionComplete: () => false,
},
},
//width: 400,
},
],
};
}

onAdd() {
this.grid2.endEdit();


//this.grid2.dataBind();
console.log(this.grid2);
console.log(this.grid2.childGrid);
console.log(this.grid2['currentViewData']);

}







1 Reply

MS Manivel Sellamuthu Syncfusion Team September 3, 2021 05:33 PM UTC

Hi Tharindu, 

Greetings from Syncfusion support. 

Query: I want to know how to get the LAST Edited grid['currentViewData']. 
 
We can get the current view data of parent and child grid by binding the actionComplete event to the Grids. In the actionComplete event of the grid based on the requestType as “save”. We can get the updated currentview data and current edited data. 

Please refer the below code example and sample for more information. 

<div class="control-section"> 
    <ejs-grid #Grid id='Grid' [editSettings]="editSettings" [dataSource]='parentData' (actionComplete)="actionComplete($event)" [toolbar]='toolbar' [childGrid]='childGrid'> 
        <e-columns> 
            <e-column field='EmployeeID' isPrimaryKey='true' headerText='Employee ID' width='120' textAlign='Right'></e-column> 
            <e-column field='FirstName' headerText='Name' width='140'></e-column> 
            <e-column field='Title' editType="dropdownedit" headerText='Title' width='170'></e-column> 
            <e-column field='HireDate' headerText='Hired Date' width='120' format='yMd' textAlign='Right'></e-column> 
            <e-column field='ReportsTo' headerText='Reports To' width='120' textAlign='Right'></e-column> 
        </e-columns> 
    </ejs-grid> 
</div> 
export class AppComponent { 
    @ViewChild('Grid', {statictrue}) 
    public grid: GridComponent; 
    public parentData: Object[]; 
    public childGrid: any; 
    public toolbar = ['Update''Cancel']; 
    public editSettings = {allowEditing: true}; 
 
    actionComplete (args) { 
if (args.requestType === 'save') { 
// here we can get the currentview data for parent grid 
console.log('Parent Grid currentViewdata'this.grid.getCurrentViewRecords()); 
// here we can get the current edited data for parent grid 
console.log('Edited data'args.data); 
} 
    } 
    ngOnInit(): void { 
        this.parentData = employeeData; 
        this.childGrid = { 
            dataSource: orderDatas, 
            queryString: 'EmployeeID', 
            allowPaging: true, 
            toolbar:['Update''Cancel'], 
            editSettings: {allowEditing: true}, 
            pageSettings: {pageSize: 6, pageCount: 5}, 
            actionComplete (args) { 
                if (args.requestType === 'save') { 
               // here we can get the currentview data for child grid 
                console.log('Child Grid currentViewdata'this.getCurrentViewRecords()); 
            // here we can get the current edited data for child grid 
                console.log('Edited data', args.data); 
                } 
                    }, 
            columns: [ 
                { field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', textAlign: 'Right', width: 120 }, 
                { field: 'ShipCity', headerText: 'Ship City', width: 120 }, 
                { field: 'Freight', headerText: 'Freight', width: 120 }, 
                { field: 'CustomerID', headerText: 'Customer ID', width: 150,   editType: 'dropdownedit', 
          edit: { 
            params: { 
              allowFiltering: true, 
              dataSource: new DataManager(hierarchyOrderdata), 
              fields: { text: 'CustomerID', value: 'CustomerID' }, 
              change: (data: any) => { 
                console.log(data); 
              }, 
              query: new Query(), 
              actionComplete: () => false, 
            }, 
          }, 
                } 
            ], 
        }; 
    } 
} 



Query: When changing the child grid dropdown value it is not updated to the JSON Array.Parents Grid Policy DropDown change Data correctly updated to the JSON Array. But Child Grid change data is not updated. 

Based on your query we can understand that the Childgrid dropdown data source is not updated in your sample. Could you please share the below details which will help us to understand your requirement and provide a better suggestion as soon as possible 

  1. Please share the datasource of ParentGrid(containerdata), childgrid(this.lineDatas) and custom datasource for dropdown(this.state)
  2. Will the childgrid data and custom datasource for dropdown have different values
  3. Do you wish to childgrid dataSource’s original data(this.lineDatas) based on the updated value in the Grid.
  4. If possible, please explain your requirement with the above shared sample
  5. Please share more about your requirement

Regards, 
Manivel 


Loader.
Up arrow icon