This is a migrated thread and some comments may be shown as answers.

How to make the first data the default?

2 Answers 89 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
NHJ
Top achievements
Rank 1
NHJ asked on 16 Dec 2019, 09:37 AM
dayDropDownEditor : function (container, options) {
 
            $('<input id="' + options.field + '" data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDropDownList({
                    suggest: true,
                    dataSource: [
                        {name: '조업' },
                        {name: '안함' }
                    ],
                    dataTextField: 'name',
                    dataValueField: 'name',
                    valuePrimitive: true,
                     
                });
        }

 

Hi,

My dropbox list is displayed correctly.

However, the default is still "", which is blank.

I tried using select and also index but it didn't work.


How can I make Dropbox default to the first data if I don't pick anything?


If I pick one, the data is imported normally.

If uneven, it is empty.

2 Answers, 1 is accepted

Sort by
0
Accepted
Hetali
Telerik team
answered on 17 Dec 2019, 08:19 PM

Hi Nam,

Thank you for the snippet. 

Looking at the ticket, I am assuming that you are adding a Kendo UI DropDownList in the Kendo UI Grid Editor using the columns.editor function and while adding a new row in the Grid, you want the default value to be added in the row when no selection is made from the DropDownList.

In order to set the default value, please define the schema.model of the Grid dataSource and set the defaultValue as seen below:

dataSource: {
  schema: {
    model: {
      id: "name",
      fields: {
        name: { type: "string" , defaultValue: "조업" }
      }
    }
  }
}

Please take a look at this Dojo example where the Grid adds the default value in the new row when no value is selected from the DropDownList.

I hope you find this information helpful. However, if I have misunderstood your query, could you please respond with the detailed behavior observed by you or update the Dojo example such that it demonstrates the behavior? I will investigate further.

Regards,
Hetali
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
NHJ
Top achievements
Rank 1
answered on 18 Dec 2019, 12:43 AM
Thank you for the answer!

Thanks to your help, the problem was solved right away.

Thank you very much!
Tags
DropDownList
Asked by
NHJ
Top achievements
Rank 1
Answers by
Hetali
Telerik team
NHJ
Top achievements
Rank 1
Share this question
or