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

DropDownList as Custom Editor for grid, unable to set initial value/text

0 Answers 112 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
GungFooMon
Top achievements
Rank 1
GungFooMon asked on 24 Apr 2012, 12:58 PM
Hi!

I am trying to define an initial value for an ajax datasource populated dropdownlist in an editor definition function for a grid column.
I have tried setting it via the text() function after initialization but it seems to get "changed" to index 0 as soon as the datasource is bound to the widget..
I also tried using a callback for the select() function, setting a value() as well as using the text() method both right after the initialization (which seems to get overwritten upon loading the data) and inside a "change" even handler for the transport attribute of the datasource; none of which helped.. please advise!

here a snippet of code i used:

"editor":
    function(container, options) {
      $('<input id="' + options.field + '" />')
          .appendTo(container)
          .kendoDropDownList({
                dataTextField: 'text',
                dataValueField: 'value',
 
                dataSource: {
                    change: function(e) {
                        var item = null;
                        $('#'+options.field).data('kendoDropDownList').ul.children().each(function(idx, elem) {
                            if($(elem).html() == options.model.rel_type) item = $(elem);
                        });
                        console.log($(item).html());
// does not select anything even tho console.log() proves that it is the correct element
                        $('#'+options.field).data('kendoDropDownList').select($(item));
                    },
                    transport: {
                        read:  {
                            url: '/relationdata/relation/relType',
                            dataType: 'json'
                        }
                    }
 
                }
          });
    }}

the grid loads fine but nothing is selected in turn.

No answers yet. Maybe you can help?

Tags
DropDownList
Asked by
GungFooMon
Top achievements
Rank 1
Share this question
or