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

datasource.fetch(callback)

3 Answers 880 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Erlend
Top achievements
Rank 2
Erlend asked on 24 Feb 2012, 06:49 PM
Is there any jsfiddle or documentation available on callback property on the fetch method on datasource or any other way of execute dom manipulation onloaded within the datasource object? Thx

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 27 Feb 2012, 09:16 AM
Hello Erlend,

The callback of fetch method is a function that will be called when the DataSource completes with the data manipulation. It is essentially the same as to handle change event of the DataSource with the only difference that the callback will be called only once.

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Erlend
Top achievements
Rank 2
answered on 27 Feb 2012, 01:38 PM
Hi,
Thanks for feedback. 

What I really was trying to achieve here was to set value(value) on a DOM ready dropdown after it had been given its datasource and list was ready based on a hidden value in the page. 
When I used this method (fetch) then it seems that the dropdown list is not DOM ready as it fails on a .call(a,b) method. 

I solved my issued with implementing a setTimeout callback to set the selected value in the dropdown list, however I don't see this as an ultimate solution. 

I was thinking something like this:
<input id="hidden" value="1"/>
<input id="input"/>
var datasource = new kendo.data.dataSouce({...});
$("#input").kendoDropDownList({dataSource: datasource});

datasource.fetch(callback);

//Here i'm getting an error when I'm trying this.
function callback(){
$("#input").data("kendoDropDownList").value($("#hidden").val());
}

Is this expected or was this never to be achieved, or is there an other way to achieve this?

Regards, 
0
Nikolay Rusev
Telerik team
answered on 29 Feb 2012, 10:07 AM
Hello Erlend,

For your convenience I'm attaching sample example implementing the scenario you've described.
http://jsfiddle.net/rusev/y5aWq/

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Erlend
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Erlend
Top achievements
Rank 2
Share this question
or