---
ADMIN EDIT: Check the source code and comments in it from the following demo to see how to bind the grid to a DataTable: https://demos.telerik.com/blazor-ui/grid/data-table. You can also examine it offline - the entire demos project is available in the "demos" folder of your installation
The sample code snippet below will let the grid show data, but will not enable complex operations like filtering and sorting. Review the demo linked above for more details on the correct approach.
---
I would like to be able to supply a DataTable with an arbitrary amount of columns to the grid and display them all without declaring them all. This should also allow paging, sorting, filtering. At the moment binding to a DataTable is not supported, only IEnumerable collections are.
At the moment, here's the closest I can get, sorting and filtering throw errors so they are disabled.
@
using
System.Data
@
using
Telerik.Blazor
@
using
Telerik.Blazor.Components.Grid
<button
class
=
"btn btn-primary"
@onclick=
"@LoadData"
>Load Data</button>
@
if
(@d !=
null
)
{
<TelerikGrid Data=@d.AsEnumerable() TItem=
"DataRow"
Sortable=
"false"
Filterable=
"false"
Pageable=
"true"
PageSize=
"3"
Height=
"400px"
>
<TelerikGridColumns>
@
foreach
(DataColumn col
in
d.Columns)
{
<TelerikGridColumn Field=
"@col.ColumnName"
Title=
"@col.ColumnName"
>
<Template>
@((context
as
DataRow).ItemArray[col.Ordinal].ToString())
</Template>
</TelerikGridColumn>
}
</TelerikGridColumns>
</TelerikGrid>
}
@functions {
DataTable d =
null
;
void
LoadData()
{
d = GetData();
}
public
DataTable GetData()
{
DataTable table =
new
DataTable();
table.Columns.Add(
"Product"
,
typeof
(
string
));
table.Columns.Add(
"Price"
,
typeof
(
double
));
table.Columns.Add(
"Quantity"
,
typeof
(
int
));
table.Columns.Add(
"AvailableFrom"
,
typeof
(DateTime));
table.Rows.Add(
"Product 1"
, 10.1, 2, DateTime.Now);
table.Rows.Add(
"Product 2"
, 1.50, 10, DateTime.Now);
table.Rows.Add(
"Product 3"
, 120.66, 5, DateTime.Now);
table.Rows.Add(
"Product 4"
, 30.05, 10, DateTime.Now);
return
table;
}
}
Sometimes, we just want a simple equal filter in grid, without operators options
---
ADMIN EDIT
If you want to modify the current behavior and layout of the filters, use the filter template (there is another example in this thread - in the post from 29 Jun 2020 that you can also use as base).
---
how to use Multiple Column Header in grid?
thanks
At the moment the numeric and date filters keep the filter button visible even on narrow columns. This must be implemented for the string filter as well - it has a set width at the moment.
The "clear filter" button must always be visible as well (when there is a filter applied, of course).
Ideally, the filter elements will also have a common container with an accessible class so, for example, you can set its max-width to 50% or 100px to match desired UI easily without hacking through several different layouts and selectors.
Currently the blazor grid must be a specific, static height. If one is not provided, the grid uses a default of 500px.
Kendo grid implementations in other UI frameworks allow for more flexibility in the height of the grid. It would be great if the blazor implementation could support this as well.
Two specific scenarios that are valueable:
1) Grid height adjusts to accomodate all of the items in the grid
For other kendo grid implementations, this is typically the case when "Scrollable" is set to false. If there is a plan to allow toggling scrolling for the blazor grid, then I think that this would come along with that.
2) Ability to set grid height to 100%
With other kendo implementations this is normally done via CSS, and is useful for when you want a "full screen" grid. This is normally combined with "Scrollable=true" and often combined with Pagination="true" as well. Currently it's not possible to do this - since the height is defined on the k-grid element, it cannot be overridden with CSS.
I discovered "incell" editing mode on the grid, I love it! It makes the UI very intuitive and quick to update individual fields. It also works great with a PATCH API endpoint.
One minor glitch with "incell editing". If I click on a cell in a different row, it immediately takes the previous cell out of edit and puts the new cell in edit with a single click -- VERY cool. But, if you click on a cell in the same row it takes the previous cell out of edit, but doesn't put the new cell in edit mode. It would be cool if it worked the same as the "clicking in separate rows" functionality.
Thanks,
Kenny
In addition to more filtering options we would like to have the ability to use custom filter components instead of the built-in ones. For example, through a cell template for the filter row.
Please comment below with how you would like to see this integrate into the data source operations of the grid (for example, should it fire an event where you filter the data you pass to the grid, or should the grid expose some method/interface that you need to use).
Dear Telerik,
I'd like to post a new feature request- > A checkbox column.
Where it is possible to select multiple rows.
Regards,
Gert
So far in the TelerikGrid component it is only possible to set the title of a column to a string. It would be useful to give the title/header a template instead of a simple string. In this way one could for example place a button, image, (...) inside the columnheader.
This kind of template-ability could be very handy in various other cases elsewhere, so please bring this flexibility into ui for blazor.
Hello there,
I am looking for the ability to display hierarchical data in the grid control similar to that available in the asp.net core grid: https://demos.telerik.com/aspnet-core/grid/hierarchy
Thanks!