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

Iterate through Kendo adatasource

5 Answers 804 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 27 Oct 2012, 02:03 PM
I am trying to iterate through a Kendo datasource using the $.map function to inspect the values.

How do I do this?

So far I have this... but I cant seem to get to the actual value...
$.map(ds.data(), function (value, index) {
           var $row = $(this);
 
           $.each($row, function (index, value) {
               alert(value.toString());
           });
 
       });


5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Oct 2012, 05:17 PM
Hello Greg,

this in the outer function is the window object, why don't you use the value parameter that you are passing?

In addition, it is worth noting that ds.data() returns an ObservableArray of Observable objects, while ds.data().toJSON() returns an ordinary array of plain objects. You may prefer using the second array, as it contains fewer child objects and only the ones you need.

$.map(ds.data().toJSON(), function (dataItem, index) {
        $.each(dataitem, function (field, value) {
            alert(field + " " + value);
        });
});

The above example assumes that the dataSource contains composite data items with multiple fields, e.g. ones that belong to the Kendo UI Grid. Simpler text-value datasources, e.g. for the Kendo UI ComboBox, can be iterated with only one loop:

$.map(ds.data().toJSON(), function (dataItem, index) {
    alert(dataItem.text + " " + dataItem.value);
});

All the best,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jyothsna
Top achievements
Rank 1
answered on 08 Mar 2017, 11:25 AM

Hi want to iterate through kendo grid.

If we use  var dataSource = grid.dataSource;

dataSource.data(); ----> This will read all data .

But on grid I am also applying filters.so I don't to  iterate all data.what i have to do...Any suggestions please

     

0
Jyothsna
Top achievements
Rank 1
answered on 08 Mar 2017, 11:27 AM
Try to respond me quickly...Thank you..WE are waiting for response
0
Jyothsna
Top achievements
Rank 1
answered on 08 Mar 2017, 11:29 AM
We are waiting for ur response.we are stucked here.

Thank you

0
Dimo
Telerik team
answered on 08 Mar 2017, 03:23 PM
Hi Jyothsna,

I assume that you need the view() method of the DataSource. It will return only the filtered items on the current page.

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-view

Regards,
Dimo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Greg
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Jyothsna
Top achievements
Rank 1
Share this question
or