how to set array values to dropdown List,here i am providing sample of code in that jobTitle column i want to set values

<ejs-grid #grid [dataSource]='rulesets'[allowPaging]='true'  [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'
    (toolbarClick)='toolbarClick($event)' (actionBegin)="actionBegin($event)">

    <e-columns>

        <e-column field='ruleSetName' headerText='RuleSet Name' textAlign='Left' [allowEditing]="true">
        </e-column>


      
            <e-column field='jobTitle'  headerText='Job'  editType='dropdownedit' minWidth="600" width="600" maxWidth="600" [allowFiltering]='false'>
                </e-column>


    </e-columns>


</ejs-grid>

1 Reply

TS Thiyagu Subramani Syncfusion Team July 30, 2021 09:07 AM UTC

Hi Sunil, 

Greeting from Syncfusion support. 

Based on your shared information we suspect that you want to set array values to dropdown List that is you want to set array values to the dropdown’s dataSource property. To achieve this requirement we suggest you to use cellEditTemplate ( create, read, write, destroy) property to the required column. By default write method to used to create custom component or assign default value at the time of editing so here we can change dropdown list values as per our needs. 


<e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit' 
                    [edit]='editparams' minWidth="600" width="600" maxWidth="600" ></e-column> 

this.editparams = { 
      create: () => { 
        this.elem = document.createElement('input'); 
        return this.elem; 
      }, 
      read: () => { 
        return this.dObj.value; 
      }, 
      destroy: () => { 
        this.dObj.destroy(); 
      }, 
      write: (args: { rowData: any; column: any }) => { 
        this.dObj = new DropDownList({ 
           // Here we can customize the dropdown by defining its properties as per our needs 
          dataSource: ['text', 'text2', 'text3'] 
        }); 
        this.dObj.appendTo(this.elem); 
      } 
    }; 


 


If we misunderstood your requirement, please share below details then only we can provide the appropriate solution as soon as possible. 

  1. Are you want to set array values to the dropdown’s value property.
  2. Explain your requirement briefly.
  3. If possible share pictorial representation of your requirement.

Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon