Updating Grid Datasource via Column DropDown change event Automatically Creates New Record

Grid has a dropdown column type, selecting a value in that dropdown can update the dropdown values in the same column for other rows. However, whenever updating the grid's datasource via dropdown's change event, everything works as expected except that the grid control adds a new record row at the top of the grid. The grid is set to allowAdding:false. How do I prevent the grid from creating that new record row. The grid edit params and dropdown edit params are set in the page oninit(). The grid and column are set up as follows:

Grid is defined as

<ejs-grid class="grid" #grid [dataSource]="localParams.linkedAccounts" (dataBound)="onGridDataBound($event)" (rowSelected)="rowSelected($event)" (load)='load($event)' (cellSave)="onCellSave($event)" (actionComplete)='onActionComplete($event)' (actionBegin)='actionBegin($event)'
(created)="onGridCreated()" [editSettings]='editSettings' [selectionSettings]="selectionOptions" [allowPaging]='false'>


this.editSettings = {allowEditing:true, allowAdding:false, allowDeleting: false, mode: "Normal" };


Primary Key column

                    <e-column field='accountNumber' isPrimaryKey="true" headerText='Account Number' clipMode='EllipsisWithTooltip'>


And a dropdown grid column defined as follows

<e-column [edit]="ddParams" field='relationshipType' headerText='Designation' foreignKeyField="value" foreignKeyValue="text" [dataSource]="accountDesignations">e-column>


this.ddParams = {
params: {
actionComplete: (args: any) =>
{
if(this.currentSelectedRow){
if(this.currentSelectedRow.accountTypeId==2){
args.result = this.ccAccountDesignations;
}
}
},
change: (args: ChangeEventArgs)=>{
var row = this.grid.dataSource[4] as Dto;
row.relationshipType = '';
this.grid.updateRow(4, row);
};

4 Replies

JO Joseph June 23, 2021 08:49 PM UTC

Can you reproduce in an isolated example?



JO Joseph June 23, 2021 10:38 PM UTC

I see the problem



JS Jamie Schmidt June 23, 2021 10:41 PM UTC

The problem was a typo in the onaction event that changed the requesttype. Removing this resolved the strange behavior.



MS Manivel Sellamuthu Syncfusion Team June 24, 2021 06:54 AM UTC

Hi Jamie, 

Greetings from Syncfusion support 

We are glad that you have resolved the issue on your own. 

Please get back to us if you need further assistance. 

Regards, 
Manivel 


Loader.
Up arrow icon