@@ -69,9 +69,37 @@ angular.module('ui.grid')
69
69
* @name data
70
70
* @propertyOf ui.grid.class:GridOptions
71
71
* @description (mandatory) Array of data to be rendered into the grid, providing the data source or data binding for
72
- * the grid. The most common case is an array of objects, where each object has a number of attributes.
72
+ * the grid.
73
+ *
74
+ * Most commonly the data is an array of objects, where each object has a number of attributes.
73
75
* Each attribute automatically becomes a column in your grid. This array could, for example, be sourced from
74
- * an angularJS $resource query request. The array can also contain complex objects.
76
+ * an angularJS $resource query request. The array can also contain complex objects, refer the binding tutorial
77
+ * for examples of that.
78
+ *
79
+ * The most flexible usage is to set your data on $scope:
80
+ *
81
+ * `$scope.data = data;`
82
+ *
83
+ * And then direct the grid to resolve whatever is in $scope.data:
84
+ *
85
+ * `$scope.gridOptions.data = 'data';`
86
+ *
87
+ * This is the most flexible approach as it allows you to replace $scope.data whenever you feel like it without
88
+ * getting pointer issues.
89
+ *
90
+ * Alternatively you can directly set the data array:
91
+ *
92
+ * `$scope.gridOptions.data = [ ];`
93
+ * or
94
+ *
95
+ * `$http.get('/data/100.json')
96
+ * .success(function(data) {
97
+ * $scope.myData = data;
98
+ * $scope.gridOptions.data = $scope.myData;
99
+ * });`
100
+ *
101
+ * Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some other
102
+ * array, you need to update $scope.gridOptions.data to point to that new array as well.
75
103
*
76
104
*/
77
105
baseOptions . data = baseOptions . data || [ ] ;
0 commit comments