I would like to be able to set Min Width parameter to a Grid Column. The behavior I expect to see is:
@GridEditMode.Incell mode does not update automatically on row change when an editortemplate is used, as below
<GridColumn Field=@nameof(ProjectRankingInfo.Ranking.Option2) Title="@Option2Title" Width="120px" Filterable="false">
<EditorTemplate>
@{
currentItem = context as ProjectRankingInfo.Ranking;
<TelerikNumericTextBox Max="10" Min="0" Step="1" @bind-Value=@currentItem.Option2 />
}
</EditorTemplate>
</GridColumn>
one must click the update button for the update to occur,
Incell works fine and updates on row change for simple grid columns
ADMIN EDIT: SOLUTION: Read the details in the following article: https://docs.telerik.com/blazor-ui/components/grid/editing/incell#notes
ADMIN EDIT: this thread is rather long and I am adding the workaround offered by René here:
<TelerikGrid Data="@GridData" OnUpdate="@UpdateHandler"> ... </TelerikGrid>I suggest adding a FieldExpression property to the GridColumn so a developer would not need to create view models and templates for simple transformations of the existing model's properties. The field expression would be used for filtering and sorting as well. Its type would be Func<T, object> or Expression<Func<T, object>>.
<TelerikGrid Data="@Persons">
<GridColumns>
<GridColumn FieldExpression="@(p => p.FirstName + " " + p.LastName)" />
</GridColumns>
</TelerikGrid>
If a developer changes the structure of the grid in a new release, such as adding or removing columns, the restore can have very unexpected results.
We get around this by storing a version number with the grid and incrementing that number when we change the grid columns. If the version number on the grid does not match the version number stored with the state, we don't restore it.
We would like to see this be more of an automatic feature of the grid.
Compare the columns in the saved state with the columns in the Grid declaration. You may need to change the way the Grid columns are declared, according to the the linked documentation. If there is inconsistency between the two collections, strip the column information from the saved state before restoring it. (This was suggested by Dimo from Telerik in a support ticket)
An alternative would just be to throw away that state when it can't be safely restored.
Problem Statement:
We have the following blazor grid:
We have enabled the GridColumnMenuSettings
Now when we open the column chooser it does not disable for the last option.
When we don't have the GridCheckboxColumn then it works as intended
The last column option is disabled
Expected Result : We don't want the check box column to be shown in the column chooser and the last option to be unchecked in the column chooser needs to be disabled.
@* Use the Template to render the list of columns and add some custom styles *@
<TelerikGrid Data="@MyData"
Pageable="true"
PageSize="5"
Width="700px"
FilterMode="@GridFilterMode.FilterMenu"
Sortable="true"
ShowColumnMenu="true">
<GridSettings>
<GridColumnMenuSettings Sortable="true"
Lockable="false"
FilterMode="@ColumnMenuFilterMode.None" />
</GridSettings>
<GridColumns>
<GridCheckboxColumn Width="80px" HeaderClass="header-select-all" />
<GridColumn Field="@(nameof(SampleData.Id))" Width="80px" Title="Id" Id="id-column-id" />
<GridColumn Field="@(nameof(SampleData.FirstName))" Title="First Name" Id="firstname-column-id" />
<GridColumn Field="@(nameof(SampleData.LastName))" Title="Last Name" Id="lastname-column-id" />
<GridColumn Field="@(nameof(SampleData.CompanyName))" Title="Company" Id="companyname-column-id" />
<GridColumn Field="@(nameof(SampleData.Team))" Title="Team" Id="team-column-id" />
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" Id="hiredate-column-id" />
</GridColumns>
</TelerikGrid>
@code {
public string TextboxValue { get; set; } = string.Empty;
public IEnumerable<SampleData> MyData = Enumerable.Range(1, 30).Select(x => new SampleData
{
Id = x,
FirstName = $"FirstName {x}",
LastName = $"LastName {x}",
CompanyName = $"Company {x}",
Team = "team " + x % 5,
HireDate = DateTime.Now.AddDays(-x).Date
});
public class SampleData
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string CompanyName { get; set; }
public string Team { get; set; }
public DateTime HireDate { get; set; }
}
}
So what I propose is a fixed width for a column of the grid (and locked) with the remaining columns auto-sizing.
In my situation, I have an action switch button where the client can delete a row, edit a row etc but the action code dropdown column needs to ALWAYS be the same width. The rest of the columns should automatically size based on the existing behaviour.
Now I have tried using the autosize for just that column, but I have to render the grid first, then run the autosize (which gives a fun show of resizing to the user) then all the columns become fixed width, but the vertical scroll bar doesn't move and stays in its initial position.
When clicking on the Add Button in a Grid, a new item is created and displayed in edit mode.
Problem is, the OnEdit event is not triggered. I need to set a default value for new items and added the code in the OnEditHandler with if(args.IsNew){ //set default value}.
Unfortunately this does not work because the event is not triggered. This makes me wonder what "args.IsNew" is for if not for the usecase described above.
It would be good to have a Grid parameter like "ExpandDetailsOnSelection" for the Grid:
-> When the user selects a row, the DetailTemplate automatically expands - the DetailTemplate of the previous selected item is automatically collapsed
Advantages:
- no "+" button needed
- easy to integrate for 2-way-binding on SelectedItems (no need to use GridState and RowClick event)
We have a Telerik grid which is customized by some CSS rules. The problem is that the header width does not fill the width of the table if no scrollbar is shown.
My question is: Why did you create the table like it is right now in HTML (See screenshot as well)? In my opinion, it would be easier to use something more simple like described here: https://www.w3schools.com/html/html_tables.asp
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
This would make it easier to customize the table / grid as well as having no issues with the widths at all. This rectangle on the right top edge doesn't look good...
I'm not sure if this is a feature request or just a discussion / idea for the developers :) I just wanted to bring this in and get an explanation why you chose to do it that way (And maybe get a fix for this as well).
Best regards,
Christian
I have a blazor grid with a large number of columns which I would like to have the width of the page and a horizontal scrollbar to be able to scroll through all of the columns.
According the the documentation I have found (https://demos.telerik.com/blazor-ui/grid/scrolling), setting the width of the grid to 100% and providing widths for the columns which exceed that of the width of the grid/page should cause the horizontal scrollbar to appear. Instead of doing this, however, the grid just expands horizontally to fit all of the columns, no matter what I try. In addition, it appears to be expanding the entire page horizontally to fit itself, as it is increasing the size of all of my bootstrap columns so that it fits within the bootstrap container.
Here is an example of a page containing a grid where I am experiencing this:
@page "/admin/users/manageusers"
@inherits ManageUsersBase
<h3>Manage Users</h3>
<WS7.Components.PDAuthorizeBase AllowedRoleIds="ManageAllUsers,ManageAssignedUsers" />
@if (this.Users == null)
{
<p><em>Loading...</em></p>
}
else
{
<div class="form-group">
<label for="UserSearch" class="col-form-label">Search</label>
<input id="UserSearch" class="form-control" type="search" aria-label="User Search" placeholder="Search" @bind-value="Filter" @bind-value:event="oninput" />
</div>
<TelerikGrid Data="@FilteredUsers" TItem="WS7.Engine.Models.ViewModels.ManageUsersViewModel" Height="600px" Width="100%" Pageable="true" PageSize="40" Sortable="true" Groupable="false"
FilterMode="GridFilterMode.FilterMenu" Resizable="true" Reorderable="true" OnEdit="EditUser" ScrollMode="@GridScrollMode.Scrollable">
<GridToolBar>
<GridCommandButton OnClick="(()=>AddUser())">
<span class="oi oi-plus"></span> Add
</GridCommandButton>
</GridToolBar>
<GridColumns>
<GridCommandColumn Width="100px">
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
</GridCommandColumn>
<GridColumn Field="UserName" Title="User Name" Width="500px" />
<GridColumn Field="Email" Title="Email" Width="500px" />
<GridColumn Field="FirstName" Title="First Name" Width="500px" />
<GridColumn Field="LastName" Title="Last Name" Width="500px" />
<GridColumn Field="AccountStatus" Title="Account Status" Width="500px">
<Template>
@{
string toolTip;
WS7.Engine.Models.ViewModels.ManageUsersViewModel user = context as WS7.Engine.Models.ViewModels.ManageUsersViewModel;
toolTip = "Account Status: " + user.AccountStatus;
toolTip += Environment.NewLine + "Active: " + user.Active.ToString();
toolTip += Environment.NewLine + "Email Confirmed: " + user.EmailConfirmed.ToString();
}
<div class="badge badge-pill badge-info">
<span class="oi oi-info" data-toggle="tooltip" data-placement="top" title="@toolTip"></span>
</div>
</Template>
</GridColumn>
@*<GridCommandColumn Width="90px">
<GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton>
</GridCommandColumn>*@
</GridColumns>
</TelerikGrid>
}
---
ADMIN EDIT
You can find some more details on the origin of the issue in the thread below and in the following Knowledge Base article, which also offers a few ideas for solutions to this browser behavior: https://docs.telerik.com/blazor-ui/knowledge-base/grid-bootstrap-flex-width-issue
---
When a user clicks outside of the edited input in the same cell, the cell remains in edit mode. The problem occurs in the 2.30.0 version.
You can see this behavior in the Incell Editing demo.
ADMIN EDIT: The issue stems from the data operations in the business logic, and it is not a bug in the component and it does not relate to WebAPI usage.
Hi there,
as a follow-up of https://feedback.telerik.com/blazor/1461176-set-specific-position-in-virtual-scrolling-mode we have implemented the suggested skip handling. But there seems an issue when the data is fetched asynchronously, specifically from an Web API.
After hours of debugging and analyzing i have narrowed it down to the following simple Blazor app showcasing the bug:
https://github.com/ViRuSTriNiTy/blazor-app-telerik-grid-skip-bug
Please clone the repo, start the application and follow the steps displayed above the grid to reproduce the bug.
The second skip followed immediatelly after the first one originates from the Telerik assembly hence i cannot investigate it further (no source code).
What are your thoughts? Is it a bug?
So lonG
Daniel
The grid should support INotifyPropertyChanged for the objects in the grid, i.e. if the data object implements INotifyPropertyChanged and a property value changes, the corresponding cell value in the grid should also change.
If in a grid columns are bound to integer values which shall be treated as enum values it can be done with the FieldType parameter.
Unfortunately the new FilterMenuType.CheckBoxList does not work as expected then.
With
<GridColumn Field="@(nameof(MyModel.MyPropertyId))"
FieldType="@(typeof(MyPropertyEnum))"
Title="MyProperty"
FilterMenuType="@FilterMenuType.CheckBoxList">
the filter shows Integers instead of Enum-Strings.
(With FilterMenuType.Menu the filter correctly treats the values as enums)
Regards,
René
Values of FilterMenu are not preserved in GridState.
If FilterRow is used instead of FilterMenu then the values are preserved in GridState.
(I believe that Filtering was preserved with FilterMenu as well in some previous version but I could be wrong.)
Regards,
René
Hello,
When using grid command button edit with the onedit handler shown in this documentation https://docs.telerik.com/blazor-ui/components/grid/editing/inline
There is a bug that causes the grid to reset to the first page when editing the last item on any page that isn't the first. In other words we can edit the last item in the gird on the first page but not on the second, third, fourth...etc.
I have taken out all the logic in my edit handler as well and the problem still presents itself.
Below is the relevenat code sample and I have also zipped a short video demonstrating the behavior.
<TelerikGrid @ref="@GridNameHere"
Class="smallerFont"
Data="@DataHere"
Pageable="true"
Page="@Page"
PageSize="@PageSize"
TotalCount="@Total"
Sortable="@true"
Groupable="@false"
FilterMode="@GridFilterMode.FilterMenu"
Reorderable="@true"
OnEdit="@OnEdit"
OnUpdate="@OnUpdate"
OnCreate="@OnUpdate">
<GridToolBar>
<GridCommandButton Command="Add" Icon="add">Add</GridCommandButton>
</GridToolBar>
<GridColumns>
<GridCommandColumn Width="150px">
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Save</GridCommandButton>
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
</GridCommandColumn>
<GridColumn Field="@(nameof(ModelName.FieldName))" Title="Column Name" Width="100px" />
</GridColumns>
</TelerikGrid>
//Handler for edit
protected void OnEdit(GridCommandEventArgs args)
{
// no code in here and problem still presents itself but feel free to put anything I recommend using the sample from the documentation above
}
Hi,
I am using a grid on a data structure that has nested properties inside. Previously, I was able to do this which worked fine: (notice the first 2 colums)
<TelerikGrid Data="@PackedInfo.PackedParts" Height="100%">
<GridColumns>
<GridColumn Field=@nameof(PackedPart.Part.PartNo) Title="Part no" />
<GridColumn Field=@nameof(PackedPart.Part.PartDescription) Title="Description" />
<GridColumn Field=@nameof(PackedPart.UnitWeightG) Title="Substance Weight" />
<GridColumn Field=@nameof(PackedPart.FlashPointCentigrade) Title="Flash point" />
<GridColumn Field=@nameof(PackedPart.Pg) Title="PG" />
<GridColumn Field=@nameof(PackedPart.Qty) Title="PG" />
</GridColumns>
</TelerikGrid>
I recently upgraded to the latest version (Telerik.UI.for.Blazor (2.29.0) and noticed that the first 2 fields are no longer displaying. I fixed this, by specifying the field names as string values:
<TelerikGrid Data="@PackedInfo.PackedParts" Height="100%">
<GridColumns>
<GridColumn Field="Part.PartNo" Title="Part no" />
<GridColumn Field="Part.PartDescription" Title="Description" />
<GridColumn Field=@nameof(PackedPart.UnitWeightG) Title="Substance Weight" />
<GridColumn Field=@nameof(PackedPart.FlashPointCentigrade) Title="Flash point" />
<GridColumn Field=@nameof(PackedPart.Pg) Title="PG" />
<GridColumn Field=@nameof(PackedPart.Qty) Title="PG" />
</GridColumns>
</TelerikGrid>
I have also tried using @nameof(Part.PartNo) but that didn't work either. Only providing nested properties as string values works. This should not be the intended behaviour i'm sure?
regards,
Chris Nateghi
----
ADMIN EDIT
The Excel export seems to honor it, so it can be used as a workaround.
Reproducible with the workaround commented out:
<TelerikButton OnClick="@CurrentPage">Current Page</TelerikButton>
<TelerikButton OnClick="@AllPages">All Pages</TelerikButton>
<TelerikGrid Data="@GridData"
@ref="@GridRef"
Pageable="true"
Sortable="true"
Resizable="true"
Reorderable="true"
FilterMode="@GridFilterMode.FilterRow"
Groupable="true">
<GridExport>
<GridExcelExport FileName="telerik-grid-export" AllPages="@ExportAllPages" />
</GridExport>
<GridColumns>
<GridColumn Field="@nameof(SampleData.ProductId)" Title="ID" Width="100px" />
<GridColumn Field="@nameof(SampleData.ProductName)" Title="Product Name" Width="300px" />
<GridColumn Field="@nameof(SampleData.UnitsInStock)" Title="In stock" Width="100px" />
<GridColumn Field="@nameof(SampleData.Price)" Title="Unit Price" Width="200px" />
<GridColumn Field="@nameof(SampleData.Discontinued)" Title="Discontinued" Width="100px" />
<GridColumn Field="@nameof(SampleData.FirstReleaseDate)" Title="Release Date" Width="300px" />
</GridColumns>
</TelerikGrid>
@code {
async Task AllPages()
{
ExportAllPages = true;
await Task.Delay(20); // allow the component to rerender with the new parameter
await GridRef.SaveAsCsvFileAsync();
//await GridRef.SaveAsExcelFileAsync(); // this works
}
async Task CurrentPage()
{
ExportAllPages = false;
await Task.Delay(20); // allow the component to rerender with the new parameter
await GridRef.SaveAsCsvFileAsync();
//await GridRef.SaveAsExcelFileAsync(); // this works
}
private TelerikGrid<SampleData> GridRef { get; set; }
List<SampleData> GridData { get; set; }
bool ExportAllPages { get; set; }
protected override void OnInitialized()
{
GridData = Enumerable.Range(1, 100).Select(x => new SampleData
{
ProductId = x,
ProductName = $"Product {x}",
UnitsInStock = x * 2,
Price = 3.14159m * x,
Discontinued = x % 4 == 0,
FirstReleaseDate = DateTime.Now.AddDays(-x)
}).ToList();
}
public class SampleData
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int UnitsInStock { get; set; }
public decimal Price { get; set; }
public bool Discontinued { get; set; }
public DateTime FirstReleaseDate { get; set; }
}
}
Internally it looks like you are using RadSpreadStreamProcessing for grid.ExportToExcelAsync() if you gave us an optional lamdba to manipulate IRowExporter while you are processing, it would make things a lot easier.
There were a couple other feature requests out there that you closed offering alternatives ways of doing this and we are actually just importing the stream back to RadSpreadProcessing object and then manipulating that way. Adding the Lambda would be a much more efficient way of handling this use case and probably very simple for you to implement.