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

Default Value for Dropdown in JavaScript grid

I am trying to set the defualt value for a a Dropdown when adding a new row. However it doesn't select anything from the dropdown, is there a differant way i should be approaching this.

//Here is the datasource 
var dateUnit= [
            { text: "Hours", value:1 },
                { text: "Days", value: 2},
        ];


//Here is the column portion
columns: [
                        { field: "Unit", headerText: "Unit", textAlign: ej.TextAlign.Center, editType: ej.Grid.EditingType.Dropdown, dataSource: dateUnit, defaultValue: 1 }
                ]

1 Reply

SA Saravanan Arunachalam Syncfusion Team September 25, 2015 08:38 AM UTC

Hi Mike,

Thanks for contacting Syncfusion Support.

We analyzed your query and we considered this query “Dropdown edit with defaultValue is not working” as a bug and a support incident has been created under your account to track the status of this issue. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents 

And also we have resolved the issue using a workaround. In the workaround, we have achieved your requirement using “actionComplete” event of Grid and we have set the default value using “setSelectedValue” method of DropDownList. Please refer to the following code example.

$("#Grid").ejGrid({

                . . .                                         

              actionComplete: function(args){

                                                                if(args.requestType == "add"){

                                                                                var drpdwn = this.getContentTable(".gridfrom").find("#GridEmployeeID").ejDropDownList("instance");

                                                                                drpdwn.setSelectedValue(1);

                                                                }

              },

             . . .

        });


We have created the sample and it can be downloaded from the following link:

http://jsplayground.syncfusion.com/qwcfzlfb

Regards,

Saravanan.A


Loader.
Live Chat Icon For mobile
Up arrow icon