/api/framework/hierarchicaldatasource.md

https://github.com/sanyaade-mobiledev/kendo-docs · Markdown · 77 lines · 56 code · 21 blank · 0 comment · 0 complexity · 2bfb56e6c5d62667bc5ad8da4a557310 MD5 · raw file

  1. ---
  2. title: kendo.data.HierarchicalDataSource
  3. meta_title: API Reference for Kendo UI Hierarchical DataSource
  4. meta_description: Learn more about the configuration of Kendo UI DataSource, methods and events.
  5. slug: fw-kendo.data.hierachicaldatasource
  6. tags: api,framework
  7. publish: true
  8. ---
  9. # kendo.data.HierarchicalDataSource
  10. ## Configuration
  11. See the [DataSource configuration](/api/framework/datasource#configuration) for all inherited configuration.
  12. ### schema.model.hasChildren `Boolean | String | Function` *(default: false)*
  13. Specifies whether the model might have children and might be loaded. Applicable when the rendering of a
  14. widget needs to have different states for items that have no children (e.g. the toggle button of the TreeView).
  15. ### schema.model.children `String | Object` *(default: "items")*
  16. DataSource object or configuration for fetching child nodes. Through examples of that can be found
  17. in the **Getting started** section above.
  18. For static HierarchicalDataSource (local data), this field may be a `String`,
  19. indicating which field holds the nested data.
  20. #### Example
  21. var localDataSource = new kendo.data.HierarchicalDataSource({
  22. data: [ {
  23. categoryName: "SciFi",
  24. movies: [
  25. { title: "Star Wars: A New Hope", year: 1977 },
  26. { title: "Star Wars: The Empire Strikes Back", year: 1980 },
  27. { title: "Star Wars: Return of the Jedi", year: 1983 }
  28. ]
  29. }, {
  30. categoryName: "Drama",
  31. movies: [
  32. { title: "The Shawshenk Redemption", year: 1994 },
  33. { title: "Fight Club", year: 1999 },
  34. { title: "The Usual Suspects", year: 1995 }
  35. ]
  36. }
  37. ],
  38. schema: {
  39. model: {
  40. children: "movies"
  41. }
  42. }
  43. });
  44. ## Methods
  45. See the [DataSource methods](/api/framework/datasource#methods) for all inherited methods.
  46. The **remove** and **getByUid** methods are overridden and work with the hierarchical data
  47. (they will act on all child datasources that have been read).
  48. ## Events
  49. See the [DataSource events](/api/framework/datasource#events) for all inherited events.
  50. ### change
  51. Fires when data is changed. In addition to the [standard change event](/api/framework/datasource#change),
  52. the HierarchicalDataSource includes additional data when the event has been triggered from a child
  53. DataSource.
  54. #### Event Data
  55. ##### e.node `Node`
  56. If the event was triggered by a child datasource, this field holds a reference to the parent node.