We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to change dynamically Edit Type of Column on change DropDown

Hi,

It's possible change the edit type of the input "Valor" dynamically when fire the event change of the Dropdown "Tipo"?

For example on change to "Numero" the input "Valor" becomes Numeric

I'm using a Dialog setting to Add,Edit and Delete Data from TreeGrid

duvida.png


Best Regards

Ricardo


1 Reply

SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team March 20, 2023 02:55 PM UTC

Hi Ricardo ,


Greeting from Syncfusion support.


Query #:- How to change dynamically Edit Type of Column on change DropDown?


It is not feasible to change the editType of the column when we change the value in another column after the component was rendered. However, we can change render different custom controls without directly changing the editType with CellEditTemplate feature of the TreeGrid. Using this Cell EditTemplate we have placed the AutoComplete and based on condition we have change it into dropdown dynamically. Likewise you can place NumericTextbox or all other required components as per your convenience.


app.component.html

<ejs-treegrid>

           <e-columns>

                   . . .

                   <e-column field='taskName' headerText='Task Name' width='200' [validationRules]='tasknamerules' [edit]='dpParams' ></e-column>

                   . . .

           </e-columns>

       </ejs-treegrid>

 


app.component.ts

export class AppComponent {

    . . .

    public dpParamsObject;

    public autoCompleteObjAutoComplete;

     @ViewChild('treegrid')

     public treegridTreeGridComponent;

    ngOnInit(): void {

        . . .

        this.dpParams = {

            create: () => {

                let elemHTMLInputElement = document.createElement('input');

                elem.id = 'taskname';

                return elem;

            },

            read: () => {

                return this.autoCompleteObj.value;

            },

            destroy: () => {

                this.autoCompleteObj.destroy();

            },

            write: (args: { rowDataObjectcolumnColumnelementHTMLElement }) => {

                this.autoCompleteObj = new AutoComplete({

                    dataSource: <{keystringvalueany}[]>this.treegrid.grid.dataSource,

                    fields: { value: 'taskName' },

                    value: args.rowData[args.column.field]

                });

                this.autoCompleteObj.appendTo(args.element);

            }

        };

    }

 

}


Please refer to the demo :- https://ej2.syncfusion.com/angular/demos/#/bootstrap5/treegrid/edittemplate


Kindly get back to us for further assistance.


Regards,

Shek Mohammed Asiq


Loader.
Live Chat Icon For mobile
Up arrow icon