|
|
|
@ -3,6 +3,7 @@ |
|
|
|
|
@using System.Linq.Dynamic.Core |
|
|
|
|
|
|
|
|
|
@inject NorthwindDataService service; |
|
|
|
|
@inject ContextMenuService contextMenuService; |
|
|
|
|
|
|
|
|
|
@rendermode RenderMode.InteractiveServer |
|
|
|
|
|
|
|
|
@ -30,9 +31,10 @@ |
|
|
|
|
</RadzenCard> |
|
|
|
|
|
|
|
|
|
<RadzenCard class="rz-p-12" Style="width: 900px"> |
|
|
|
|
<RadzenText TextStyle="TextStyle.H5">DataGrid <strong>Virtualization</strong></RadzenText> |
|
|
|
|
<RadzenText TextStyle="TextStyle.H5">DataGrid <strong>Virtualization & ContextMenu</strong></RadzenText> |
|
|
|
|
|
|
|
|
|
<RadzenDataGrid Data="@vtzdCustomers" Style="height:500px" |
|
|
|
|
<RadzenDataGrid TItem="@Customer" Data="@vtzdCustomers" @bind-Value="selectedVtzdCustomers" Style="height:500px" |
|
|
|
|
CellContextMenu="@OnCellContextMenu" |
|
|
|
|
AllowVirtualization="true" |
|
|
|
|
SelectionMode="DataGridSelectionMode.Single" |
|
|
|
|
AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false" FilterMode="FilterMode.CheckBoxList" AllowSorting="true"> |
|
|
|
@ -49,10 +51,10 @@ |
|
|
|
|
<RadzenDataGridColumn Property="@nameof(Customer.Fax)" Filterable="true" Title="Fax" Width="160px" TextAlign="TextAlign.Center" /> |
|
|
|
|
</Columns> |
|
|
|
|
</RadzenDataGrid> |
|
|
|
|
<RadzenText TextStyle="TextStyle.Body1" Text="@message"/> |
|
|
|
|
</RadzenCard> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code { |
|
|
|
|
readonly int PAGE_SIZE = 10; |
|
|
|
|
|
|
|
|
@ -94,10 +96,27 @@ |
|
|
|
|
|
|
|
|
|
// Virtualization |
|
|
|
|
IEnumerable<Customer> vtzdCustomers; |
|
|
|
|
|
|
|
|
|
IList<Customer> selectedVtzdCustomers; |
|
|
|
|
string message = "Message: "; |
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
|
|
{ |
|
|
|
|
var result = await service.GetCustomer(); |
|
|
|
|
vtzdCustomers = result.Value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnCellContextMenu(DataGridCellMouseEventArgs<Customer> args) |
|
|
|
|
{ |
|
|
|
|
selectedVtzdCustomers = new List<Customer>() { args.Data }; |
|
|
|
|
|
|
|
|
|
contextMenuService.Open(args, |
|
|
|
|
new List<ContextMenuItem> { |
|
|
|
|
new ContextMenuItem(){ Text = "ContextMenuItem 1", Value = 1, Icon = "home" }, |
|
|
|
|
new ContextMenuItem(){ Text = "ContextMenuItem 2", Value = 2, Icon = "search" }, |
|
|
|
|
new ContextMenuItem(){ Text = "ContextMenuItem 3", Value = 3, Icon = "info" }, |
|
|
|
|
}, |
|
|
|
|
e => { |
|
|
|
|
message = $"Message: Menu item cliked! Value={e.Value} | Column: {args.Column.Property} | CustomerID: {args.Data.CustomerID}"; |
|
|
|
|
InvokeAsync(StateHasChanged); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|