Skip to content

Commit 36e13bd

Browse files
authored
Merge pull request #1 from SyncfusionExamples/Correction
Corrected spelling mistake
2 parents f1bba34 + 23e5dd2 commit 36e13bd

File tree

8 files changed

+96
-116
lines changed

8 files changed

+96
-116
lines changed
791 KB
Loading

Binding MS SQL database using CustomAdaptor/Blazor Web app/Grid_MSSQL/Grid_MSSQL/Grid_MSSQL/Components/Pages/Home.razor

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
</GridAggregate>
4343
</GridAggregates>
4444
<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>
4747
<GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="150"></GridColumn>
4848
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Format="C2" Width="150"></GridColumn>
4949
<GridColumn Field=@nameof(Order.ShipCity) HeaderText="Ship City" Width="150"></GridColumn>
@@ -61,10 +61,10 @@
6161
/// <summary>
6262
/// Returns the data collection after performing data operations based on request from <see cref=”DataManagerRequest”/>
6363
/// </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>
6666
/// <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)
6868
{
6969
IEnumerable<Order> DataSource = await OrderService.GetOrdersAsync();
7070
// Handling Searching in Custom Adaptor.
@@ -86,6 +86,12 @@
8686
DataSource = DataOperations.PerformSorting(DataSource, DataManagerRequest.Sorted);
8787
}
8888
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+
}
8995
// Handling Paging in Custom Adaptor. For example, Skip is 0 and Take is equal to page size for first page.
9096
if (DataManagerRequest.Skip != 0)
9197
{
@@ -96,32 +102,8 @@
96102
{
97103
DataSource = DataOperations.PerformTake(DataSource, DataManagerRequest.Take);
98104
}
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-
}
124105
// Handling Grouping in Custom Adaptor.
106+
DataResult DataObject = new DataResult();
125107
if (DataManagerRequest.Group != null)
126108
{
127109
IEnumerable ResultData = DataSource.ToList();
@@ -132,21 +114,26 @@
132114
}
133115
DataObject.Result = ResultData;
134116
DataObject.Count = count;
117+
//If both Grouping and Aggregate is enabled
118+
if (DataManagerRequest.Aggregates != null)
119+
{
120+
DataObject.Aggregates = Aggregates;
121+
}
135122
//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.
136123
// In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side.
137124
return DataManagerRequest.RequiresCounts ? DataObject : (object)ResultData;
138125
}
139126
//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.
140127
// 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;
142129
}
143130

144131
/// <summary>
145132
/// Inserts a new data item into the data collection.
146133
/// </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>
150137
/// <returns>Returns the newly inserted record details.</returns>
151138
public override async Task<object> InsertAsync(DataManager DataManager, object Value, string Key)
152139
{
@@ -157,12 +144,12 @@
157144
/// <summary>
158145
/// Updates an existing data item in the data collection.
159146
/// </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>
164151
/// <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)
166153
{
167154
// 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.
168155
await OrderService.UpdateOrderAsync(Value as Order);
@@ -172,12 +159,12 @@
172159
/// <summary>
173160
/// Removes a data item from the data collection.
174161
/// </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>
179166
/// <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)
181168
{
182169
// Given that the key column is identified nullable interger type in the DataGrid, the primaryColumnValue can be utilized from Value property directly.
183170
await OrderService.RemoveOrderAsync(Value as int?);

Binding MS SQL database using CustomAdaptor/Blazor Web app/Grid_MSSQL/Grid_MSSQL/Grid_MSSQL/Data/OrderData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace Grid_MSSQL.Data
55
{
66
public class OrderData
77
{
8-
//Enter the connectionstring of database
9-
public string ConnectionString = <Enter your connectionstring here>;
8+
//TODO: Enter the connectionstring of database
9+
public string ConnectionString = @"<Enter a valid connection string>";
1010
public async Task<List<Order>> GetOrdersAsync()
1111
{
1212
//Create query to fetch data from database
@@ -42,7 +42,7 @@ public async Task AddOrderAsync(Order Value)
4242
Connection.Open();
4343
//Execute the SQL Command
4444
SqlCommand SqlCommand = new SqlCommand(Query, Connection);
45-
//Exceute this code to reflect the changes into the database
45+
//Execute this code to reflect the changes into the database
4646
SqlCommand.ExecuteNonQuery();
4747
Connection.Close();
4848
}
@@ -55,7 +55,7 @@ public async Task UpdateOrderAsync(Order Value)
5555
Connection.Open();
5656
//Execute the SQL Command
5757
SqlCommand SqlCommand = new SqlCommand(Query, Connection);
58-
//Exceute this code to reflect the changes into the database
58+
//Execute this code to reflect the changes into the database
5959
SqlCommand.ExecuteNonQuery();
6060
Connection.Close();
6161
}
@@ -68,7 +68,7 @@ public async Task RemoveOrderAsync(int? Key)
6868
Connection.Open();
6969
//Execute the SQL Command
7070
SqlCommand SqlCommand = new SqlCommand(Query, Connection);
71-
//Exceute this code to reflect the changes into the database
71+
//Execute this code to reflect the changes into the database
7272
SqlCommand.ExecuteNonQuery();
7373
Connection.Close();
7474
}

Binding MS SQL database using UrlAdaptor/Blazor WASM app/Grid_MSSQL/Grid_MSSQL/Pages/Home.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
</GridAggregate>
3838
</GridAggregates>
3939
<GridColumns>
40-
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsIdentity="true" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
41-
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
40+
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsIdentity="true" ValidationRules="@(new ValidationRules{ Required= true })" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
41+
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required= true, MinLength = 3 })" Width="150"></GridColumn>
4242
<GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee ID" TextAlign="TextAlign.Right" Width="150"></GridColumn>
4343
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Format="C2" Width="150"></GridColumn>
4444
<GridColumn Field=@nameof(Order.ShipCity) HeaderText="Ship City" Width="150"></GridColumn>

0 commit comments

Comments
 (0)