|
42 | 42 | </GridAggregate> |
43 | 43 | </GridAggregates> |
44 | 44 | <GridColumns> |
45 | | - <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsIdentity="true" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> |
46 | | - <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> |
| 45 | + <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" ValidationRules="@(new ValidationRules{ Required= true })" IsIdentity="true" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> |
| 46 | + <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required= true, MinLength = 3 })" Width="150"></GridColumn> |
47 | 47 | <GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="150"></GridColumn> |
48 | 48 | <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Format="C2" Width="150"></GridColumn> |
49 | 49 | <GridColumn Field=@nameof(Order.ShipCity) HeaderText="Ship City" Width="150"></GridColumn> |
|
61 | 61 | /// <summary> |
62 | 62 | /// Returns the data collection after performing data operations based on request from <see cref=”DataManagerRequest”/> |
63 | 63 | /// </summary> |
64 | | - /// <param name="dataManagerRequest">DataManagerRequest containes the information regarding paging, grouping, filtering, searching which is handled on the DataGrid component side</param> |
65 | | - /// <param name="additionalParam">An optional parameter that can be used to perform additional data operations.</param> |
| 64 | + /// <param name="DataManagerRequest">DataManagerRequest contains the information regarding paging, grouping, filtering, searching which is handled on the DataGrid component side</param> |
| 65 | + /// <param name="Key">An optional parameter that can be used to perform additional data operations.</param> |
66 | 66 | /// <returns>The data collection's type is determined by how this method has been implemented.</returns> |
67 | | - public override async Task<object> ReadAsync(DataManagerRequest DataManagerRequest, string key = null) |
| 67 | + public override async Task<object> ReadAsync(DataManagerRequest DataManagerRequest, string Key = null) |
68 | 68 | { |
69 | 69 | IEnumerable<Order> DataSource = await OrderService.GetOrdersAsync(); |
70 | 70 | // Handling Searching in Custom Adaptor. |
|
86 | 86 | DataSource = DataOperations.PerformSorting(DataSource, DataManagerRequest.Sorted); |
87 | 87 | } |
88 | 88 | int count = DataSource.Cast<Order>().Count(); |
| 89 | + // Handling Aggregates in Custom Adaptor. |
| 90 | + IDictionary<string, object> Aggregates = null; |
| 91 | + if (DataManagerRequest.Aggregates != null) // Aggregation |
| 92 | + { |
| 93 | + Aggregates = DataUtil.PerformAggregation(DataSource, DataManagerRequest.Aggregates); |
| 94 | + } |
89 | 95 | // Handling Paging in Custom Adaptor. For example, Skip is 0 and Take is equal to page size for first page. |
90 | 96 | if (DataManagerRequest.Skip != 0) |
91 | 97 | { |
|
96 | 102 | { |
97 | 103 | DataSource = DataOperations.PerformTake(DataSource, DataManagerRequest.Take); |
98 | 104 | } |
99 | | - // Handling Aggregates and Group in Custom Adaptor. |
100 | | - DataResult DataObject = new DataResult(); |
101 | | - if (DataManagerRequest.Aggregates != null) // Aggregation |
102 | | - { |
103 | | - if (DataManagerRequest.Group != null) |
104 | | - { |
105 | | - // For Aggregate alone |
106 | | - IEnumerable ResultData = DataSource.ToList(); |
107 | | - //For Grouping |
108 | | - foreach (var group in DataManagerRequest.Group) |
109 | | - { |
110 | | - ResultData = DataUtil.Group<Order>(ResultData, group, DataManagerRequest.Aggregates, 0, DataManagerRequest.GroupByFormatter); |
111 | | - } |
112 | | - DataObject.Result = ResultData; |
113 | | - } |
114 | | - else |
115 | | - { |
116 | | - DataObject.Result = DataSource; |
117 | | - } |
118 | | - DataObject.Count = count; |
119 | | - DataObject.Aggregates = DataUtil.PerformAggregation(DataSource, DataManagerRequest.Aggregates); |
120 | | - //Here RequiresCount is passed from the control side itself, where ever the ondemand data fetching is needed then the RequiresCount is set as true in component side itself. |
121 | | - // In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side. |
122 | | - return DataManagerRequest.RequiresCounts ? DataObject : (object)DataSource; |
123 | | - } |
124 | 105 | // Handling Grouping in Custom Adaptor. |
| 106 | + DataResult DataObject = new DataResult(); |
125 | 107 | if (DataManagerRequest.Group != null) |
126 | 108 | { |
127 | 109 | IEnumerable ResultData = DataSource.ToList(); |
|
132 | 114 | } |
133 | 115 | DataObject.Result = ResultData; |
134 | 116 | DataObject.Count = count; |
| 117 | + //If both Grouping and Aggregate is enabled |
| 118 | + if (DataManagerRequest.Aggregates != null) |
| 119 | + { |
| 120 | + DataObject.Aggregates = Aggregates; |
| 121 | + } |
135 | 122 | //Here RequiresCount is passed from the control side itself, where ever the ondemand data fetching is needed then the RequiresCount is set as true in component side itself. |
136 | 123 | // In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side. |
137 | 124 | return DataManagerRequest.RequiresCounts ? DataObject : (object)ResultData; |
138 | 125 | } |
139 | 126 | //Here RequiresCount is passed from the control side itself, where ever the ondemand data fetching is needed then the RequiresCount is set as true in component side itself. |
140 | 127 | // In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side. |
141 | | - return DataManagerRequest.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource; |
| 128 | + return DataManagerRequest.RequiresCounts ? new DataResult() { Result = DataSource, Count = count, Aggregates = Aggregates } : (object)DataSource; |
142 | 129 | } |
143 | 130 |
|
144 | 131 | /// <summary> |
145 | 132 | /// Inserts a new data item into the data collection. |
146 | 133 | /// </summary> |
147 | | - /// <param name="dataManager">The DataManager is a data management component used for performing data operations in applications.</param> |
148 | | - /// <param name="record">The new record which is need to be inserted.</param> |
149 | | - /// <param name="additionalParam">An optional parameter that can be used to perform additional data operations.</param> |
| 134 | + /// <param name="DataManager">The DataManager is a data management component used for performing data operations in application.</param> |
| 135 | + /// <param name="Value">The new record which is need to be inserted.</param> |
| 136 | + /// <param name="Key">An optional parameter that can be used to perform additional data operations.</param> |
150 | 137 | /// <returns>Returns the newly inserted record details.</returns> |
151 | 138 | public override async Task<object> InsertAsync(DataManager DataManager, object Value, string Key) |
152 | 139 | { |
|
157 | 144 | /// <summary> |
158 | 145 | /// Updates an existing data item in the data collection. |
159 | 146 | /// </summary> |
160 | | - /// <param name="dataManager">The DataManager is a data management component used for performing data operations in applications.</param> |
161 | | - /// <param name="record">The modified record which is need to be updated.</param> |
162 | | - /// <param name="primaryColumnName">The primaryColumnName specifies the field name of the primary column.</param> |
163 | | - /// <param name="additionalParam">An optional parameter that can be used to perform additional data operations.</param> |
| 147 | + /// <param name="DataManager">The DataManager is a data management component used for performing data operations in application.</param> |
| 148 | + /// <param name="Value">The modified record which is need to be updated.</param> |
| 149 | + /// <param name="KeyField">The Key field specifies the field name of the primary column.</param> |
| 150 | + /// <param name="Key">An optional parameter that can be used to perform additional data operations.</param> |
164 | 151 | /// <returns>Returns the updated data item.</returns> |
165 | | - public override async Task<object> UpdateAsync(DataManager DataManager, object Value, string keyField, string key) |
| 152 | + public override async Task<object> UpdateAsync(DataManager DataManager, object Value, string KeyField, string Key) |
166 | 153 | { |
167 | 154 | // Given that the Value property consists of modified record details. It can be used to update the changes into database by calling the predefined logic. |
168 | 155 | await OrderService.UpdateOrderAsync(Value as Order); |
|
172 | 159 | /// <summary> |
173 | 160 | /// Removes a data item from the data collection. |
174 | 161 | /// </summary> |
175 | | - /// <param name="dataManager">The DataManager is a data management component used for performing data operations in applications.</param> |
176 | | - /// <param name="primaryColumnValue">The primaryColumnValue specifies the primary column value which is needs to be removed from the grid record.</param> |
177 | | - /// <param name="primaryColumnName">The primaryColumnName specifies the field name of the primary column.</param> |
178 | | - /// <param name="additionalParam">An optional parameter that can be used to perform additional data operations.</param> |
| 162 | + /// <param name="DataManager">The DataManager is a data management component used for performing data operations in application.</param> |
| 163 | + /// <param name="Value">The primary column value specifies the primary column value which is needs to be removed from the grid record.</param> |
| 164 | + /// <param name="KeyField">The primary column name specifies the field name of the primary column.</param> |
| 165 | + /// <param name="Key">An optional parameter that can be used to perform additional data operations.</param> |
179 | 166 | /// <returns>Returns the removed data item.</returns> |
180 | | - public override async Task<object> RemoveAsync(DataManager DataManager, object Value, string keyField, string key) |
| 167 | + public override async Task<object> RemoveAsync(DataManager DataManager, object Value, string KeyField, string Key) |
181 | 168 | { |
182 | 169 | // Given that the key column is identified nullable interger type in the DataGrid, the primaryColumnValue can be utilized from Value property directly. |
183 | 170 | await OrderService.RemoveOrderAsync(Value as int?); |
|
0 commit comments