Edit this page

view

Returns the data items which correspond to the current page, filter, sort and group configuration. Compare with the data method, which will return data items from all pages, if local data binding and paging are used.

To ensure that data is available this method should be used within the change event handler or the fetch method.

Returns

kendo.data.ObservableArray the data items. Returns groups if the data items are grouped (via the group option or the group method).

Example - get the paged and sorted data items

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Tea", category: "Beverages" },
    { name: "Coffee", category: "Beverages" },
    { name: "Ham", category: "Food" }
  ],
  pageSize: 1,
  page: 2,
  sort: { field: "category", dir: "desc" }
});
dataSource.fetch(function() {
  var view = dataSource.view();
  console.log(view.length); // displays "1"
  console.log(view[0].name); // displays "Tea"
});
</script>

Example - get the paged, sorted and grouped data items

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Tea", category: "Beverages" },
    { name: "Coffee", category: "Beverages" },
    { name: "Ham", category: "Food" }
  ],
  group: { field: "category" },
  sort: { field: "name", dir: "asc" },
  pageSize: 2,
  page: 1
});
dataSource.fetch(function() {
  var view = dataSource.view();
  console.log(view.length); // displays "1"
  var beverages = view[0];
  console.log(beverages.value); // displays "Beverages"
  console.log(beverages.items.length); // displays "2"
  console.log(beverages.items[0].name); // displays "Coffee"
  console.log(beverages.items[1].name); // displays "Tea"
});
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy