If you create a second Grid on the page, it will clear the SearchBox input value of the first Grid.
<p><TelerikButton OnClick="@ToggleSecondGrid">Toggle Second Grid</TelerikButton></p>
<TelerikGrid Data="@GridData">
<GridToolBar>
<GridSearchBox />
</GridToolBar>
<GridColumns>
<GridColumn Field=@nameof(Product.ProductName) Title="Product Name" />
</GridColumns>
</TelerikGrid>
@if (ShowSecondGrid)
{
<TelerikGrid Data="@( new List<Product>() )">
<GridColumns>
<GridColumn />
</GridColumns>
</TelerikGrid>
}
@code {
List<Product> GridData { get; set; }
bool ShowSecondGrid { get; set; }
async Task ToggleSecondGrid()
{
ShowSecondGrid = !ShowSecondGrid;
}
protected override void OnInitialized()
{
GridData = new List<Product>();
for (int i = 1; i <= 5; i++)
{
GridData.Add(new Product()
{
ProductId = i,
ProductName = "Product " + i.ToString(),
UnitPrice = (decimal)(i * 3.14),
UnitsInStock = (short)(i * 1),
Discontinued = false
});
}
}
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal? UnitPrice { get; set; }
public short? UnitsInStock { get; set; }
public bool Discontinued { get; set; }
}
}
Does the Blazor grid have any support for any or all queries on sub-property collections? I would like to have the grid OnRead be able to generate a query against a sub-entity collection.
E.g.
GET serviceRoot/People?$filter=Emails/any(s:endswith(s, 'contoso.com'))
From what I can tell the Column.FieldName property only will generate a valid query for scalar properties. Is there any way to make this work?
Given the Northwind OData sample https://demos.telerik.com/kendo-ui/service-v4/odata. I would like to display a grid of all customers. In the grid, I would like to have a column that provides filtering for the orders shipper column as in the query below.
https://demos.telerik.com/kendo-ui/service-v4/odata/Customers?$expand=Orders&$filter=Orders/any(d: contains(d/Shipper/CompanyName,'Speedy Express'))
There does not seem to be a way for the in-built filter mechanism to use a lambda and it seems like there should be.
I want to place the Pager on top of the Grid. I know it can be handled with a Pager component integration in the Grid Toolbar, but I want to use the Toolbar for other purposes/actions. Please allow control over the Pager position.
Expose GroupableSettings with an option to specify whether to render the group footer. The possible values should be always (like current implementation), or when the group is expanded. An example (just for demonstration) api would be:
```
<GridSettings>
<GridGroupableSettings Footer="@GridGroupableFooterVisible.Always | @GridGroupableFooterVisible.Expanded"></GridGroupableSettings>
</GridSettings>
```
Key events will allow developers to enhance and customize the Grid keyboard navigation. For example -
Detect when the user presses the down-arrow key when on the last grid row. We want to force a "next page" when they do this, and a "previous page" if they are at the top of the grid and press the up-arrow key.
---
ADMIT EDIT
Everyone, please feel free to list other scenarios as well.
Consider the following example. It will trigger AmbiguousMatchException, because reflection discovers two SpecialProp properties.
<TelerikGrid TItem="@GridModel"
Data="@GridData"
AutoGenerateColumns="true">
</TelerikGrid>
@code {
List<GridModel> GridData { get; set; } = new();
protected override void OnInitialized()
{
for (int i = 1; i <= 3; i++)
{
GridData.Add(new GridModel()
{
SpecialProp = i,
Text = "Text " + (i * 111)
});
}
}
public record GridModel : Base1 { }
public record Base1 : Base2
{
public new decimal? SpecialProp { get => base.SpecialProp / base.HelperProp.GetValueOrDefault(1); set => base.SpecialProp = value.HasValue ? (int)(value.GetValueOrDefault() * base.HelperProp.GetValueOrDefault(1)) : null; }
}
public record Base2
{
public int? SpecialProp { get; set; }
public string Text { get; set; }
public int? HelperProp = 10;
}
}
Why not replace
private PropertyInfo FieldPropertyInfo => ContainerGenericArgument?.GetProperty(Field);
with something like
PropertyInfo FieldPropertyInfo = ContainerGenericArgument?.GetProperties().FirstOrDefault(p => p.Name == Field);
with the possibility to cache the result from GetProperties()?
Description
OnRead event is triggered multiple times when the page is different from the first one and the page size is changed.
Reproduction (if bug)
1. Create a grid and set the pageable and page sizes options
2. Navigate to a page different from the first one.
3. Change the page size.
4. The OnRead event is triggered twice.
Sample REPL for reproduction.
Browser (if bug)
All
Project type (if bug)
All
Last working version of Telerik UI for Blazor (if regression)
3.5.0
I have a Grid with numerous columns and I am using inline editing. When in edit mode, I'd like to add custom content to each cell - for example, a validation error message from server validation.
To achieve that, I have to use EditorTemplate. However, I want to keep the default editor because I'd like to avoid having to add the relevant control for every single cell each time I add a new Grid.
I have a Grid with Navigable="true" and FilterRow. If I focus a string filter input and press the left/right arrow keys, the focus moves away from the cell. This behavior also occurs when I press up/down arrows in numeric filter inputs.
Reproduction: https://blazorrepl.telerik.com/GcvPkekt36Mxgygv07.
A nice feature would be frozen Group Rows.
So if you grouped your data in the Grid and scroll. The Group should stick underneath the header.
As an example look here: https://www.ag-grid.com/angular-data-grid/grouping-sticky-groups/
Are there any plans to have the datagrid be both groupable and draggable?
Thanks,
Andy
I have a Grid bound to ObservableCollection and I try to add a new record, the Grid stays in edit mode even if I click the Save button.
Workaround:
@using System.Collections.ObjectModel
@using Telerik.FontIcons
<TelerikGrid Data="@Cards"
Height="800px"
FilterMode="GridFilterMode.FilterRow"
EditMode="GridEditMode.Inline"
OnCreate="NewCard"
OnUpdate="UpdateCard"
OnDelete="DeleteCard"
ConfirmDelete="true"
@ref="@GridReference">
<GridToolBarTemplate>
<GridCommandButton Command="Add" Icon="@FontIcon.Plus">New</GridCommandButton>
</GridToolBarTemplate>
<GridColumns>
<GridColumn Field="@nameof(AdminCard.SerialNumber)" Title="Serial number" />
<GridColumn Field="@nameof(AdminCard.DisplayNumber)" Title="Display number" />
<GridColumn Field="@nameof(AdminCard.Name)" />
<GridCommandColumn Width="140px">
<GridCommandButton Command="Save" Icon="@FontIcon.Save" ShowInEdit="true" />
<GridCommandButton Command="Edit" Icon="@FontIcon.Pencil" />
<GridCommandButton Command="Delete" Icon="@FontIcon.Trash" />
<GridCommandButton Command="Cancel" Icon="@FontIcon.Cancel" ShowInEdit="true" />
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
@code {
TelerikGrid<AdminCard> GridReference { get; set; }
public ObservableCollection<AdminCard> Cards { get; set; } = new();
protected override async Task OnInitializedAsync() =>
Cards = new ObservableCollection<AdminCard>{
new AdminCard{SerialNumber="123", DisplayNumber="1234 1234", Name="Jim"}
};
private async Task NewCard(GridCommandEventArgs args)
{
AdminCard card = (AdminCard)args.Item;
Cards.Add(card);
//apply this after saving the new record to the database
var gridState = GridReference.GetState();
gridState.InsertedItem = null;
gridState.OriginalEditItem = null;
await GridReference.SetStateAsync(gridState);
}
private async Task UpdateCard(GridCommandEventArgs args)
{
AdminCard fromGrid = (AdminCard)args.Item;
AdminCard existing = Cards.Single(c => c.Id == fromGrid.Id);
existing.SerialNumber = fromGrid.SerialNumber;
existing.DisplayNumber = fromGrid.DisplayNumber;
existing.Name = fromGrid.Name;
}
private async Task DeleteCard(GridCommandEventArgs args)
{
AdminCard card = (AdminCard)args.Item;
Cards.Remove(card);
}
public class AdminCard
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string SerialNumber { get; set; } = "";
public string DisplayNumber { get; set; } = "";
public string Name { get; set; } = "";
}
}