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

Dropdown issue/questions

3 Answers 118 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 29 Jun 2016, 05:37 PM

I have an angular directive that wraps a virtual kendo ui dropdown.  The issue i'm having is that even though i am setting the dataValueField when i select an dropdown item the k-ng-model bound field is set to the entire item object rather than  the property of the object specified by the dataValueField.  Not sure what i'm doing wrong.

 

var selectDataSource = new kendo.data.DataSource({
            transport: {
              read: function(options) {
                var currentPage = getItemPage(options.data.skip, options.data.take);
                options.success(currentPage);
              }
            },
            schema: {
              data: "currentPage",
              total: "total"
            },
            pageSize: pageSize,
            serverPaging: true // enable serverPaging so take and skip are sent as
          });  
 
        //setup the dropdown options object
        scope.dropDownListOptions = {
          dataTextField: scope.textField,    // 'name' 
          dataValueField: scope.valueField,  // 'id'
          dataSource: selectDataSource,
          height: height,
          virtual: {
            itemHeight: 26,
            valueMapper: function(options) {
                var itemIndex = scope.itemList.findIndex(function(element, index, array){
                return options.value === element[scope.textField];
              });
              options.success(itemIndex);
            }
          }
        }

 

 

/*directive html*/

<select id="{{selectId}}"
        kendo-drop-down-list 
        k-options="dropDownListOptions" 
        k-ng-model="modelValue"></select>

 

The other question relates to the optionLabel default option.  Is there any way to disable this option so that the user can't select it?

 

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Jul 2016, 08:12 AM
Hello Michael,

I would suggest you check the k-ng-model documentation and more specifically the k-value-primitive support:

http://docs.telerik.com/kendo-ui/AngularJS/introduction#the-k-value-primitive-attribute

Regards,
Georgi Krustev
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Michael
Top achievements
Rank 1
answered on 01 Jul 2016, 02:12 PM
That fixed the one issue.  However i need to find a way to prevent the user from selecting the default optionLabel.  I don't want them selecting this.  Is there any way to disable/prevent the uses from selecting this/disable it?
0
Michael
Top achievements
Rank 1
answered on 01 Jul 2016, 06:30 PM

Figured out a fix:

 

open: function () { $('.k-list-optionlabel').hide(); },

Tags
DropDownList
Asked by
Michael
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or