Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,32 @@
public override async Task<object> ReadAsync(DataManagerRequest DataManagerRequest, string Key = null)
{
IEnumerable<Order> DataSource = await OrderService.GetOrdersAsync();
// Handling Searching in Custom Adaptor.
// Handling Searching in CustomAdaptor.
if (DataManagerRequest.Search != null && DataManagerRequest.Search.Count > 0)
{
// Searching
DataSource = DataOperations.PerformSearching(DataSource, DataManagerRequest.Search);
}
// Handling Filtering in Custom Adaptor.
// Handling Filtering in CustomAdaptor.
if (DataManagerRequest.Where != null && DataManagerRequest.Where.Count > 0)
{
// Filtering
DataSource = DataOperations.PerformFiltering(DataSource, DataManagerRequest.Where, DataManagerRequest.Where[0].Operator);
}
// Handling Sorting in Custom Adaptor.
// Handling Sorting in CustomAdaptor.
if (DataManagerRequest.Sorted != null && DataManagerRequest.Sorted.Count > 0)
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, DataManagerRequest.Sorted);
}
int count = DataSource.Cast<Order>().Count();
// Handling Aggregates in Custom Adaptor.
int TotalRecordsCount = DataSource.Cast<Order>().Count();
// Handling Aggregates in CustomAdaptor.
IDictionary<string, object> Aggregates = null;
if (DataManagerRequest.Aggregates != null) // Aggregation
{
Aggregates = DataUtil.PerformAggregation(DataSource, DataManagerRequest.Aggregates);
}
// Handling Paging in Custom Adaptor. For example, Skip is 0 and Take is equal to page size for first page.
// Handling Paging in CustomAdaptor. For example, Skip is 0 and Take is equal to page size for first page.
if (DataManagerRequest.Skip != 0)
{
//Paging
Expand All @@ -102,7 +102,7 @@
{
DataSource = DataOperations.PerformTake(DataSource, DataManagerRequest.Take);
}
// Handling Grouping in Custom Adaptor.
// Handling Grouping in CustomAdaptor.
DataResult DataObject = new DataResult();
if (DataManagerRequest.Group != null)
{
Expand All @@ -113,19 +113,19 @@
ResultData = DataUtil.Group<Order>(ResultData, group, DataManagerRequest.Aggregates, 0, DataManagerRequest.GroupByFormatter);
}
DataObject.Result = ResultData;
DataObject.Count = count;
DataObject.Count = TotalRecordsCount;
//If both Grouping and Aggregate is enabled
if (DataManagerRequest.Aggregates != null)
{
DataObject.Aggregates = Aggregates;
}
//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.
// In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side.
//Here RequiresCount is passed from the control side itself, where ever the on-demand data fetching is needed then the RequiresCount is set as true in component side itself.
// In the above case we are using paging so datas are loaded in on-demand bases whenever the next page is clicked in DataGrid side.
return DataManagerRequest.RequiresCounts ? DataObject : (object)ResultData;
}
//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.
// In the above case we are using Paging so datas are loaded in ondemand bases whenever the next page is clicked in DataGrid side.
return DataManagerRequest.RequiresCounts ? new DataResult() { Result = DataSource, Count = count, Aggregates = Aggregates } : (object)DataSource;
//Here RequiresCount is passed from the control side itself, where ever the on-demand data fetching is needed then the RequiresCount is set as true in component side itself.
// In the above case we are using paging so datas are loaded in on-demand bases whenever the next page is clicked in DataGrid side.
return DataManagerRequest.RequiresCounts ? new DataResult() { Result = DataSource, Count = TotalRecordsCount, Aggregates = Aggregates } : (object)DataSource;
}

/// <summary>
Expand Down Expand Up @@ -170,6 +170,43 @@
await OrderService.RemoveOrderAsync(Value as int?);
return Value;
}

/// <summary>
/// /// Batchupdate (Insert, Update, Delete) a collection of data items from the data collection.
/// </summary>
/// <param name="DataManager">The DataManager is a data management component used for performing data operations in application.</param>
/// <param name="Changed">The Changed specifies the collection of record updated in batch mode which needs to be updated from the grid record.</param>
/// <param name="Added">The Added specifies the collection of record inserted in batch mode which needs to be inserted from the grid record.</param>
/// <param name="Deleted">The Deleted specifies the collection of record deleted in batch mode which needs to be removed from the grid record.</param>
/// <param name="KeyField">The KeyField specifies the field name of the primary column.</param>
/// <param name="Key">An optional parameter that can be used to perform additional data operations.</param>
/// <param name="DropIndex">An optional parameter that can be used to perform row drag and drop operation.</param>
/// <returns>Returns the removed data item.</returns>
public override async Task<object> BatchUpdateAsync(DataManager DataManager, object Changed, object Added, object Deleted, string KeyField, string Key, int? DropIndex)
{
if (Changed != null)
{
foreach (var record in (IEnumerable<Order>)Changed)
{
await OrderService.UpdateOrderAsync(record as Order);
}
}
if (Added != null)
{
foreach (var record in (IEnumerable<Order>)Added)
{
await OrderService.AddOrderAsync(record as Order);
}
}
if (Deleted != null)
{
foreach (var record in (IEnumerable<Order>)Deleted)
{
await OrderService.RemoveOrderAsync((record as Order).OrderID);
}
}
return Key;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task<List<Order>> GetOrdersAsync()
Connection.Open();
// Using SqlDataAdapter, process the query string and fill the data into the dataset
Adapter.Fill(Data);
//Cast the data fetched from Adapter to List<T>
//Cast the data fetched from SqlDataAdapter to List<T>
Orders = Data.Tables[0].AsEnumerable().Select(r => new Order
{
OrderID = r.Field<int>("OrderID"),
Expand Down
3 changes: 2 additions & 1 deletion Binding MS SQL database using CustomAdaptor/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# blazor-grid-mssql-connectivity-using-custom-adaptor
# Blazor Grid Microsoft SQL Server connectivity using CustomAdaptor

A project that enables data binding and CRUD action handling in the Syncfusion Blazor DataGrid to a Microsoft SQL Server using CustomAdaptor feature of the Grid.

## Steps to run the sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ public class GridController : ControllerBase
public object Post([FromBody] DataManagerRequest DataManagerRequest)
{
IEnumerable<Order> DataSource = GetOrderData();
// Handling Searching in Url Adaptor.
// Handling Searching in UrlAdaptor.
if (DataManagerRequest.Search != null && DataManagerRequest.Search.Count > 0)
{
// Searching
DataSource = DataOperations.PerformSearching(DataSource, DataManagerRequest.Search);
}
// Handling Filtering in Url Adaptor.
// Handling Filtering in UrlAdaptor.
if (DataManagerRequest.Where != null && DataManagerRequest.Where.Count > 0)
{
// Filtering
DataSource = DataOperations.PerformFiltering(DataSource, DataManagerRequest.Where, DataManagerRequest.Where[0].Operator);
}
// Handling Sorting in Url Adaptor.
// Handling Sorting in UrlAdaptor.
if (DataManagerRequest.Sorted != null && DataManagerRequest.Sorted.Count > 0)
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, DataManagerRequest.Sorted);
}
int count = DataSource.Cast<Order>().Count();
// Handling Aggregation in Url Adaptor.
int TotalRecordsCount = DataSource.Cast<Order>().Count();
// Handling Aggregation in UrlAdaptor.
IDictionary<string, object> Aggregates = null;
if (DataManagerRequest.Aggregates != null) // Aggregation
{
Aggregates = DataUtil.PerformAggregation(DataSource, DataManagerRequest.Aggregates);
}
// Handling Paging in Url Adaptor.
// Handling Paging in UrlAdaptor.
if (DataManagerRequest.Skip != 0)
{
// Paging
Expand All @@ -58,7 +58,7 @@ public object Post([FromBody] DataManagerRequest DataManagerRequest)
}
//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.
// In the above case we are using Paging so data are loaded in ondemand bases whenever the next page is clicked in DataGrid side.
return new { result = DataSource, count = count, aggregates = Aggregates };
return new { result = DataSource, count = TotalRecordsCount, aggregates = Aggregates };
}
[Route("api/[controller]")]
public List<Order> GetOrderData()
Expand All @@ -76,7 +76,7 @@ public List<Order> GetOrderData()
// Using SqlDataAdapter, process the query string and fill the data into the dataset
DataAdapter.Fill(DataTable);
sqlConnection.Close();
//Cast the data fetched from Adaptor to List<T>
//Cast the data fetched from SqlDataAdapter to List<T>
var DataSource = (from DataRow Data in DataTable.Rows
select new Order()
{
Expand Down Expand Up @@ -162,7 +162,7 @@ public void Delete([FromBody] CRUDModel<Order> Value)
[HttpPost]
[Route("api/Grid/Batch")]
/// <summary>
/// Batch update (Insert, Update, Delete) a collection of data item from the data collection.
/// Batch update (Insert, Update, Delete) a collection of data items from the data collection.
/// </summary>
/// <param name="CRUDModel<T>">The set of information along with details about the CRUD actions to be executed from the database.</param>
/// <returns>Returns void</returns>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# blazor-grid-mssql-connectivity-using-url-adaptor
# Blazor DataGrid Microsoft SQL Server connectivity using UrlAdaptor

A project that enables data binding and CRUD action handling in the Syncfusion Blazor DataGrid to a Microsoft SQL Server using UrlAdaptor feature.

## Steps to run the sample

1. Download or unzip the project
1. Download or unzip the project

2. This project consist of two applications so open and run both MyWebService and GridWASM_MSSQL_UrlAdaptor projects in Visual Studio 2022

2. Open ServerExplorer tab in Visual Studio of MyWebService project.
3. Open ServerExplorer tab in Visual Studio of MyWebService project.

3. Add NORTHWND.MDF database located in the App_Data folder of MyWebService project into the application.
4. Add NORTHWND.MDF database located in the App_Data folder of MyWebService project into the application.

4. Replace connected database's connectionstring in GridController.cs file in Controllers folder.
5. Replace connected database's connectionstring in GridController.cs file in Controllers folder.

5. Run the application
6. Run the application
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ public class GridController : ControllerBase
public object Post([FromBody] DataManagerRequest DataManagerRequest)
{
IEnumerable<Order> DataSource = GetOrderData();
// Handling Searching in Url Adaptor.
// Handling Searching in UrlAdaptor.
if (DataManagerRequest.Search != null && DataManagerRequest.Search.Count > 0)
{
// Searching
DataSource = DataOperations.PerformSearching(DataSource, DataManagerRequest.Search);
}
// Handling Filtering in Url Adaptor.
// Handling Filtering in UrlAdaptor.
if (DataManagerRequest.Where != null && DataManagerRequest.Where.Count > 0)
{
// Filtering
DataSource = DataOperations.PerformFiltering(DataSource, DataManagerRequest.Where, DataManagerRequest.Where[0].Operator);
}
// Handling Sorting in Url Adaptor.
// Handling Sorting in UrlAdaptor.
if (DataManagerRequest.Sorted != null && DataManagerRequest.Sorted.Count > 0)
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, DataManagerRequest.Sorted);
}
int count = DataSource.Cast<Order>().Count();
// Handling Aggregation in Url Adaptor.
int TotalRecordsCount = DataSource.Cast<Order>().Count();
// Handling Aggregation in UrlAdaptor.
IDictionary<string, object> Aggregates = null;
if (DataManagerRequest.Aggregates != null) // Aggregation
{
Aggregates = DataUtil.PerformAggregation(DataSource, DataManagerRequest.Aggregates);
}
// Handling paging in Url Adaptor.
// Handling paging in UrlAdaptor.
if (DataManagerRequest.Skip != 0)
{
// Paging
Expand All @@ -61,7 +61,7 @@ public object Post([FromBody] DataManagerRequest DataManagerRequest)
}
//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.
// In the above case we are using Paging so data are loaded in ondemand bases whenever the next page is clicked in DataGrid side.
return new { result = DataSource, count = count };
return new { result = DataSource, count = TotalRecordsCount };
}
[Route("api/[controller]")]
public List<Order> GetOrderData()
Expand All @@ -77,7 +77,7 @@ public List<Order> GetOrderData()
// Using SqlDataAdapter, process the query string and fill the data into the dataset
DataAdapter.Fill(DataTable);
sqlConnection.Close();
//Cast the data fetched from Adaptor to List<T>
//Cast the data fetched from SqlDataAdapter to List<T>
var DataSource = (from DataRow Data in DataTable.Rows
select new Order()
{
Expand Down Expand Up @@ -153,7 +153,7 @@ public void Delete([FromBody] CRUDModel<Order> Value)
[HttpPost]
[Route("api/Grid/Batch")]
/// <summary>
/// Batch update (Insert, Update, Delete) a collection of data item from the data collection.
/// Batch update (Insert, Update, Delete) a collection of data items from the data collection.
/// </summary>
/// <param name="CRUDModel<T>">The set of information along with details about the CRUD actions to be executed from the database.</param>
/// <returns>Returns void</returns>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# blazor-grid-mssql-connectivity-using-url-adaptor
# Blazor DataGrid Microsoft SQL Server connectivity using UrlAdaptor

A project that enables data binding and CRUD action handling in the Syncfusion Blazor DataGrid to a Microsoft SQL Server using UrlAdaptor feature.

## Steps to run the sample
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grid_MySQL", "Grid_MySQL\Grid_MySQL\Grid_MySQL.csproj", "{ADBACDFB-124F-4938-AABB-6AC1BA645F72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grid_MySQL.Client", "Grid_MySQL\Grid_MySQL.Client\Grid_MySQL.Client.csproj", "{F11A0E8A-139E-4EC4-89B5-4477D0F0DDBC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ADBACDFB-124F-4938-AABB-6AC1BA645F72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADBACDFB-124F-4938-AABB-6AC1BA645F72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADBACDFB-124F-4938-AABB-6AC1BA645F72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADBACDFB-124F-4938-AABB-6AC1BA645F72}.Release|Any CPU.Build.0 = Release|Any CPU
{F11A0E8A-139E-4EC4-89B5-4477D0F0DDBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F11A0E8A-139E-4EC4-89B5-4477D0F0DDBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F11A0E8A-139E-4EC4-89B5-4477D0F0DDBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F11A0E8A-139E-4EC4-89B5-4477D0F0DDBC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB5C8E3B-2684-4F7E-931C-7726F7F5A388}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@page "/counter"
@rendermode InteractiveAuto

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using Grid_MySQL.Client
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Loading