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

Grid will not manually populate value set as dropdownedit

Hi,

I need to manually set the values of the dropdown in an editable Grid. These are hardcoded values and will not come from the database. I am currently setting the code like this:

{
                        field: 'Currency',
                        width: 200,
                        params: {
                            dataSource: [{ text: 'USD' }, { text: 'GBP' }, { text: 'EUR' }],
                        },
                        editType: 'dropdownedit', 
                        headerText: 'Currency'


                    },


However the drop-down is just empty.

See video for replicated problem: http://www.youtube.com/watch?v=zt5lmckCvEk

Thanks

Craig




3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team March 21, 2019 06:49 AM UTC

Hi Craig, 

Greetings from Syncfusion. 

Based on your query we suspect that you want to apply dataSource for the dropdown in Grid’s column. So, we suggest you to follow the below code example to achieve your requirement. 


ej.base.enableRipple(true); 
    var data = [{OrderID: 10248, CustomerID: "VINET", Freight: 32.38, Currency: 'USD'}, {OrderID: 10249, CustomerID: "TOMSP", Freight: 11.61, Currency:'USD'}]; 
 
    var grid = new ej.grids.Grid({ 
        dataSource: data, 
        editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition:'Top' }, 
        
        toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'], 
 
        columns: [ 
            { 
                field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', textAlign: 'Right', 
                validationRules: { required: true, number: true }, width: 140 
            }, 
            { 
                field: 'CustomerID', headerText: 'Customer ID', 
                validationRules: { required: true }, width: 140 
            }, 
            { 
                field: 'Freight', headerText: 'Freight', textAlign: 'Right', editType: 'numericedit', 
                width: 140, format: 'C2', validationRules: { required: true } 
            }, 
            { 
                field: 'Currency',  editType: 'dropdownedit', width: 150, 
                edit: {  
                   params: {  
                       query: new ej.data.Query(),   
                       dataSource: [{ text: 'USD' }, { text: 'GBP'}, { text: 'EUR'}], 
                       fields:{text:'text',value:'text'}  
                   }  
                } 
            } 
        ], 
    }); 
    grid.appendTo('#Grid'); 


We have prepared a simple sample in the following stackblitz link. 


Refer the help documentation. 



Regards, 
Thavasianand S. 



CR Craig March 21, 2019 07:22 AM UTC

That resolved the issue. I hadn't wrapped the params object inside an edit object



TS Thavasianand Sankaranarayanan Syncfusion Team March 21, 2019 08:45 AM UTC

Hi Craig, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.

Loader.
Live Chat Icon For mobile
Up arrow icon