Skip to content

Commit f680553

Browse files
committed
Prepared AutoComplete Binding samples
1 parent 435973b commit f680553

40 files changed

+926
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
11+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="25.2.7" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoCompleteBindingSamples", "AutoCompleteBindingSamples.csproj", "{A3D85E76-B818-4B1E-BF0F-BAE6A239A03A}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{A3D85E76-B818-4B1E-BF0F-BAE6A239A03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{A3D85E76-B818-4B1E-BF0F-BAE6A239A03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{A3D85E76-B818-4B1E-BF0F-BAE6A239A03A}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{A3D85E76-B818-4B1E-BF0F-BAE6A239A03A}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@page
2+
@model AutoCompleteBindingSamples.Pages.ArrayOfComplex
3+
4+
@{
5+
List<Complex> data = new List<Complex>();
6+
data.Add(new Complex() { Country = new Country() { CountryId = "Australia" }, Code = new Code() { Id = "AU" } });
7+
data.Add(new Complex() { Country = new Country() { CountryId = "Bermuda" }, Code = new Code() { Id = "BM" } });
8+
data.Add(new Complex() { Country = new Country() { CountryId = "Canada" }, Code = new Code() { Id = "CA" } });
9+
data.Add(new Complex() { Country = new Country() { CountryId = "Cameroon" }, Code = new Code() { Id = "CM" } });
10+
data.Add(new Complex() { Country = new Country() { CountryId = "Denmark" }, Code = new Code() { Id = "DK" } });
11+
data.Add(new Complex() { Country = new Country() { CountryId = "France" }, Code = new Code() { Id = "FR" } });
12+
}
13+
14+
<div class="control-wrapper">
15+
<div id="default" style='padding-top:75px;margin:0 auto;width:250px;'>
16+
<ejs-autocomplete id="country" datasource="@data" placeholder="Select a Country" popupheight="220px">
17+
<e-autocomplete-fields value="Country.CountryId"></e-autocomplete-fields>
18+
</ejs-autocomplete>
19+
</div>
20+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
3+
namespace AutoCompleteBindingSamples.Pages;
4+
5+
public class ArrayOfComplex : PageModel
6+
{
7+
public void OnGet()
8+
{
9+
10+
}
11+
}
12+
public class Code
13+
{
14+
public string Id { get; set; }
15+
}
16+
17+
public class Country
18+
{
19+
public string CountryId { get; set; }
20+
}
21+
public class Complex
22+
{
23+
public Country Country { get; set; }
24+
public Code Code { get; set; }
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@page
2+
@model AutoCompleteBindingSamples.Pages.BindRemoteData
3+
4+
@{
5+
var data = new BindingRecord().RecordModelList();
6+
}
7+
8+
<div class="control-wrapper">
9+
<div id="default" style='padding-top:75px;margin:0 auto;width:250px;'>
10+
<ejs-autocomplete id="records" dataSource="@data" placeholder="e.g. Item 1" allowFiltering="true" enableVirtualization="true" popupheight="200px">
11+
<e-data-manager adaptor="WebApiAdaptor" url="https://services.syncfusion.com/aspnet/production/api/Orders" crossDomain="true"></e-data-manager>
12+
<e-autocomplete-fields value="OrderID" ></e-autocomplete-fields>
13+
</ejs-autocomplete>
14+
</div>
15+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
3+
namespace AutoCompleteBindingSamples.Pages;
4+
5+
public class BindRemoteData : PageModel
6+
{
7+
public void OnGet()
8+
{
9+
10+
}
11+
}
12+
public class BindingRecord
13+
{
14+
public string ID { get; set; }
15+
public string Text { get; set; }
16+
public List<BindingRecord> RecordList { set; get; }
17+
public List<BindingRecord> RecordModelList()
18+
{
19+
return Enumerable.Range(1, 150).Select(i => new BindingRecord()
20+
{
21+
ID = i.ToString(),
22+
Text = "Item " + i,
23+
}).ToList();
24+
}
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.AspNetCore.Mvc.RazorPages;
4+
5+
namespace AutoCompleteBindingSamples.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@page
2+
@model AutoCompleteBindingSamples.Pages.Grouping
3+
4+
@{
5+
var data = new GroupingRecord().RecordModelList();
6+
}
7+
8+
<div class="control-wrapper">
9+
<div id="default" style='padding-top:75px;margin:0 auto;width:250px;'>
10+
<ejs-autocomplete id="records" dataSource="@data" placeholder="e.g. Item 1" allowFiltering="true" enableVirtualization="true" popupheight="200px">
11+
<e-autocomplete-fields groupBy="Group" value="Text" ></e-autocomplete-fields>
12+
</ejs-autocomplete>
13+
</div>
14+
</div>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
3+
namespace AutoCompleteBindingSamples.Pages;
4+
5+
public class Grouping : PageModel
6+
{
7+
public void OnGet()
8+
{
9+
10+
}
11+
}
12+
public class GroupingRecord
13+
{
14+
public string ID { get; set; }
15+
public string Text { get; set; }
16+
public string Group { get; set; }
17+
public List<GroupingRecord> RecordList { set; get; }
18+
public List<GroupingRecord> RecordModelList()
19+
{
20+
Random random = new Random();
21+
return Enumerable.Range(1, 150).Select(i => new GroupingRecord()
22+
{
23+
ID = i.ToString(),
24+
Text = "Item " + i,
25+
Group = GetRandomGroup(random),
26+
27+
}).ToList();
28+
}
29+
public string GetRandomGroup(Random random)
30+
{
31+
// Generate a random number between 1 and 4 to determine the group
32+
int randomGroup = random.Next(1, 5);
33+
switch (randomGroup)
34+
{
35+
case 1:
36+
return "Group A";
37+
case 2:
38+
return "Group B";
39+
case 3:
40+
return "Group C";
41+
case 4:
42+
return "Group D";
43+
default:
44+
return string.Empty;
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)