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.
Unfortunately, activation email could not send to your email. Please try again.

Default Value for Dropdown in JavaScript grid

Thread ID:

Created:

Updated:

Platform:

Replies:

120552 Sep 24,2015 04:37 PM Sep 25,2015 04:38 AM JavaScript 1
loading
Tags: ejGrid
Mike Rosenberger
Asked On September 24, 2015 04:37 PM

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 }
                ]

Saravanan Arunachalam [Syncfusion]
Replied On September 25, 2015 04:38 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;