Skip to content

Commit adf4d8a

Browse files
committed
Prepared UG samples for Blazor PreDefinedDialog, DropDownMenu and DropDownList components
1 parent f5c4dee commit adf4d8a

File tree

210 files changed

+7279
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+7279
-0
lines changed

DropDownList/Client/App.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.8" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.8" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.DropDowns" Version="20.2.0.49" />
13+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="20.2.0.49" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\Shared\DropDownListUGSample.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<table>
2+
<tr>
3+
<td><a href="BindValue">BindValue</a></td>
4+
<td><a href="IndexValueBinding">IndexValueBinding</a></td>
5+
</tr>
6+
</table>
7+
8+
9+
<style>
10+
a {
11+
padding-right: 75px;
12+
}
13+
</style>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@page "/BindValue"
2+
3+
@using Syncfusion.Blazor.DropDowns
4+
<BindRoute></BindRoute>
5+
6+
<p>DropDownList value is:<strong>@DropVal</strong></p>
7+
8+
<SfDropDownList TValue="string" Placeholder="e.g. Australia" TItem="Country" @bind-Value="@DropVal" DataSource="@Countries">
9+
<DropDownListFieldSettings Value="Name"></DropDownListFieldSettings>
10+
</SfDropDownList>
11+
12+
@code {
13+
14+
public string DropVal;
15+
16+
public class Country
17+
{
18+
public string Name { get; set; }
19+
20+
public string Code { get; set; }
21+
}
22+
23+
List<Country> Countries = new List<Country>
24+
{
25+
new Country() { Name = "Australia", Code = "AU" },
26+
new Country() { Name = "Bermuda", Code = "BM" },
27+
new Country() { Name = "Canada", Code = "CA" },
28+
new Country() { Name = "Cameroon", Code = "CM" },
29+
};
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@page "/IndexValueBinding"
2+
3+
@using Syncfusion.Blazor.DropDowns
4+
<BindRoute></BindRoute>
5+
6+
<SfAutoComplete TValue="string" Placeholder="e.g. Australia" TItem="Country" @bind-Index="@ddlIndex" DataSource="@Countries">
7+
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
8+
</SfAutoComplete>
9+
10+
@code {
11+
12+
private int? ddlIndex { get; set; } = 1;
13+
14+
public class Country
15+
{
16+
public string Name { get; set; }
17+
18+
public string Code { get; set; }
19+
}
20+
21+
List<Country> Countries = new List<Country>
22+
{
23+
new Country() { Name = "Australia", Code = "AU" },
24+
new Country() { Name = "Bermuda", Code = "BM" },
25+
new Country() { Name = "Canada", Code = "CA" },
26+
new Country() { Name = "Cameroon", Code = "CM" },
27+
};
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@page "/ArrayOfComplexData"
2+
3+
@using Syncfusion.Blazor.DropDowns
4+
<SourceRoute></SourceRoute>
5+
6+
<SfDropDownList TValue="string" TItem="Complex" Placeholder="e.g. Select a country" DataSource="@LocalData">
7+
<DropDownListFieldSettings Text="Country.CountryID" Value="Code.ID"></DropDownListFieldSettings>
8+
</SfDropDownList>
9+
10+
@code {
11+
12+
public IEnumerable<Complex> LocalData { get; set; } = new Complex().GetData();
13+
14+
public class Code
15+
{
16+
public string ID { get; set; }
17+
}
18+
19+
public class Country
20+
{
21+
public string CountryID { get; set; }
22+
}
23+
24+
public class Complex
25+
{
26+
public Country Country { get; set; }
27+
public Code Code { get; set; }
28+
public List<Complex> GetData()
29+
{
30+
List<Complex> Data = new List<Complex>();
31+
Data.Add(new Complex() { Country = new Country() { CountryID = "Australia" }, Code = new Code() { ID = "AU" } });
32+
Data.Add(new Complex() { Country = new Country() { CountryID = "Bermuda" }, Code = new Code() { ID = "BM" } });
33+
Data.Add(new Complex() { Country = new Country() { CountryID = "Canada" }, Code = new Code() { ID = "CA" } });
34+
Data.Add(new Complex() { Country = new Country() { CountryID = "Cameroon" }, Code = new Code() { ID = "CM" } });
35+
Data.Add(new Complex() { Country = new Country() { CountryID = "Denmark" }, Code = new Code() { ID = "DK" } });
36+
Data.Add(new Complex() { Country = new Country() { CountryID = "France" }, Code = new Code() { ID = "FR" } });
37+
return Data;
38+
}
39+
}
40+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@page "/ArrayOfJSONData"
2+
3+
@using Syncfusion.Blazor.DropDowns
4+
<SourceRoute></SourceRoute>
5+
6+
<SfDropDownList TValue="string" TItem="Country" Placeholder="e.g. Australia" DataSource="@Countries">
7+
<DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings>
8+
</SfDropDownList>
9+
10+
@code {
11+
12+
public class Country
13+
{
14+
public string Name { get; set; }
15+
16+
public string Code { get; set; }
17+
}
18+
19+
List<Country> Countries = new List<Country>
20+
{
21+
new Country() { Name = "Australia", Code = "AU" },
22+
new Country() { Name = "Bermuda", Code = "BM" },
23+
new Country() { Name = "Canada", Code = "CA" },
24+
new Country() { Name = "Cameroon", Code = "CM" },
25+
new Country() { Name = "Denmark", Code = "DK" },
26+
new Country() { Name = "France", Code = "FR" },
27+
new Country() { Name = "Finland", Code = "FI" },
28+
new Country() { Name = "Germany", Code = "DE" },
29+
new Country() { Name = "Greenland", Code = "GL" },
30+
new Country() { Name = "Hong Kong", Code = "HK" },
31+
new Country() { Name = "India", Code = "IN" },
32+
new Country() { Name = "Italy", Code = "IT" },
33+
new Country() { Name = "Japan", Code = "JP" },
34+
new Country() { Name = "Mexico", Code = "MX" },
35+
new Country() { Name = "Norway", Code = "NO" },
36+
new Country() { Name = "Poland", Code = "PL" },
37+
new Country() { Name = "Switzerland", Code = "CH" },
38+
new Country() { Name = "United Kingdom", Code = "GB" },
39+
new Country() { Name = "United States", Code = "US" },
40+
};
41+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@page "/BindRemoteData"
2+
3+
@using Syncfusion.Blazor.Data
4+
@using Syncfusion.Blazor.DropDowns
5+
<SourceRoute></SourceRoute>
6+
7+
<SfDropDownList TValue="string" TItem="OrderDetails" Placeholder="Select a customer" Query="@Query">
8+
<SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/Orders" Adaptor="Syncfusion.Blazor.Adaptors.ODataV4Adaptor" CrossDomain=true></SfDataManager>
9+
<DropDownListFieldSettings Text="CustomerID" Value="OrderID"></DropDownListFieldSettings>
10+
</SfDropDownList>
11+
12+
@code {
13+
public Query Query = new Query().Select(new List<string> { "CustomerID", "OrderID" }).Take(6).RequiresCount();
14+
15+
public class OrderDetails
16+
{
17+
public int? OrderID { get; set; }
18+
public string CustomerID { get; set; }
19+
public int? EmployeeID { get; set; }
20+
public double? Freight { get; set; }
21+
public string ShipCity { get; set; }
22+
public bool Verified { get; set; }
23+
public DateTime? OrderDate { get; set; }
24+
public string ShipName { get; set; }
25+
public string ShipCountry { get; set; }
26+
public DateTime? ShippedDate { get; set; }
27+
public string ShipAddress { get; set; }
28+
}
29+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@page "/BindingDynamicObject"
2+
3+
@using Syncfusion.Blazor.DropDowns
4+
@using System.Dynamic
5+
<SourceRoute></SourceRoute>
6+
7+
<SfDropDownList TValue="string" TItem="DynamicDictionary" Placeholder="Select a name" DataSource="@Orders">
8+
<DropDownListFieldSettings Text="CustomerName" Value="CustomerName"></DropDownListFieldSettings>
9+
</SfDropDownList>
10+
11+
@code {
12+
public List<DynamicDictionary> Orders = new List<DynamicDictionary>() { };
13+
protected override void OnInitialized()
14+
{
15+
Orders = Enumerable.Range(1, 15).Select((x) =>
16+
{
17+
dynamic d = new DynamicDictionary();
18+
d.OrderID = 1000 + x;
19+
d.CustomerName = (new string[] { "Nancy", "Andrew", "Janet", "Margaret", "Steven", "Michael", "Robert", "Anne", "Nige", "Fuller", "Dodsworth", "Leverling", "Callahan", "Suyama", "Davolio" }[x - 1]);
20+
return d;
21+
}).Cast<DynamicDictionary>().ToList<DynamicDictionary>();
22+
}
23+
public class DynamicDictionary : System.Dynamic.DynamicObject
24+
{
25+
Dictionary<string, object> dictionary = new Dictionary<string, object>();
26+
public override bool TryGetMember(GetMemberBinder binder, out object result)
27+
{
28+
string name = binder.Name;
29+
return dictionary.TryGetValue(name, out result);
30+
}
31+
public override bool TrySetMember(SetMemberBinder binder, object value)
32+
{
33+
dictionary[binder.Name] = value;
34+
return true;
35+
}
36+
//The GetDynamicMemberNames method of DynamicObject class must be overridden and return the property names to perform data operation and editing while using DynamicObject.
37+
public override System.Collections.Generic.IEnumerable<string> GetDynamicMemberNames()
38+
{
39+
return this.dictionary?.Keys;
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)