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:
the grid loads fine but nothing is selected in turn.
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.