We're currently working on requiring a Google CASA Security Assessment, as part of this they scanned our site.
However, the scan found an eval() function in the telerik-blazor.js file:
if(_util.isNodeJS){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}
Is it possible to remove eval() from telerik-blazor.js?
We have a tile layout control within a tab page used on the whole page, we have resizing and moving enabled by dragging. Works well on desktop however on ios safari users are unable to scroll on the page, instead the page either does not move or tiles resize/move. If we disable only resizable or reorderable, the page is still not scrollable.
===
ADMIN EDIT
===
The only option for the time being is to disable resizing and reordering on mobile devices.
I am trying to display a related virtual entity from an object in Grid. The List of objects is loaded using Entity Framework Core. I am certain that the related entities are loaded;
The transactions object that is returned ultimately to the TelerikGrid.Data definitely contain the related fields (checked with breakpoint).
<TelerikGrid @ref="@SafexTransactionGrid"
Data=@SafexContractTransactionGridData
ConfirmDelete="true"
Pageable="true"
Groupable="true"
Sortable="true"
FilterMode="GridFilterMode.FilterMenu"
Resizable="true"
Reorderable="true"
EditMode="GridEditMode.Popup"
SelectionMode="GridSelectionMode.Multiple"
PageSize="15"
Navigable="true">
<GridColumns>
...
<GridColumn Field="@nameof(SafexContractTransaction.Trader.Name)" Title="Trader Name" Editable="false"/>
...
</GridColumns>
</TelerikGrid>
@code {
private List<SafexContractTransaction> SafexContractTransactionGridData
{
get
{
// returns all the data including populated Trader property
return FourtyTwoUnitOfWork.SafexContractTransactionRepo.GetAll(SafexContractGrid.SelectedItems);;
}
}
}
private TelerikGrid<SafexContractTransaction> SafexTransactionGrid { get; set; }
}
Yet when the grid is displayed it does not contain the property.
How can I solve this?
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; }
}
}
I have the foreign key issue that is described here:
https://docs.telerik.com/blazor-ui/knowledge-base/grids-foreign-key
I am working with your grid and trying to implement the filter template. I am using the sample code on this page under the section Filter Menu Template:
https://docs.telerik.com/blazor-ui/components/grid/templates/filter
For the text to display I want to use a List of objects that have 2 properties: an id and a text to display.
I have used the grouping header template and the editor template successfully with the foreign key.
My issue with the filter template is as follows:
1. Run the attached project
2. drop down the list
3. select one item
4. press Filter (this works fine)
5. drop down the list
6. unselect the selected field
7. press Filter (this does not work – the list is still filtered)
I have enabled the Column Menu and I am using a Filter Menu Template with only one TextBox. With this setup I am able to only type one letter before the Filter Context is reset.
Reproduction: https://blazorrepl.telerik.com/wnYxagGE14oxMFH659.
When using the Filter Menu inside the Column Menu filter value is reset if Rebind is called. For reference, if using FIlter Row or a standalone Filter Menu value is not reset upon invoking Rebind.
Reproduction: https://blazorrepl.telerik.com/mdOJYHas48vPCPUv47.
Consider this test page: https://blazorrepl.telerik.com/cSEQOTQY53LRL4je36
This happens only when using a column menu - ShowColumnMenu="true".
===
A possible workaround is to use a FilterButtonsTemplate and clear the filters programmatically if the filter descriptor is empty:
@using Telerik.DataSource
@using Telerik.DataSource.Extensions
<TelerikGrid TItem="@Employee"
OnRead="@OnReadHandler"
Pageable="true"
FilterMode="@GridFilterMode.FilterMenu"
FilterMenuType="@FilterMenuType.CheckBoxList"
ShowColumnMenu="true"
Height="400px">
<GridColumns>
<GridColumn Field="@(nameof(Employee.EmployeeId))" Filterable="false" />
<GridColumn Field="@nameof(Employee.Name)">
<FilterMenuTemplate Context="context">
<TelerikCheckBoxListFilter Data="@NameOptions"
Field="@(nameof(NameFilterOption.Name))"
@bind-FilterDescriptor="@context.FilterDescriptor">
</TelerikCheckBoxListFilter>
</FilterMenuTemplate>
<FilterMenuButtonsTemplate Context="filterContext">
<TelerikButton OnClick="@( async () => await ApplyFilterAsync(filterContext) )"
ThemeColor="primary">Filter</TelerikButton>
<TelerikButton OnClick="@( async () => await ClearFilterAsync(filterContext) )">Clear</TelerikButton>
</FilterMenuButtonsTemplate>
</GridColumn>
<GridColumn Field="@nameof(Employee.Team)" Title="Team">
<FilterMenuTemplate Context="context">
<TelerikCheckBoxListFilter Data="@TeamsList"
Field="@(nameof(TeamNameFilterOption.Team))"
@bind-FilterDescriptor="@context.FilterDescriptor">
</TelerikCheckBoxListFilter>
</FilterMenuTemplate>
</GridColumn>
<GridColumn Field="@nameof(Employee.IsOnLeave)" Title="On Vacation" />
</GridColumns>
</TelerikGrid>
@code {
List<Employee> AllGridData { get; set; }
#region custom-filter-data
List<TeamNameFilterOption> TeamsList { get; set; }
List<NameFilterOption> NameOptions { get; set; }
private async Task ApplyFilterAsync(FilterMenuTemplateContext filterContext)
{
var hasFilters = filterContext.FilterDescriptor.FilterDescriptors.OfType<FilterDescriptor>().Any(x => !string.IsNullOrEmpty(x.Value.ToString()));
if (hasFilters)
{
await filterContext.FilterAsync();
}
else
{
await filterContext.ClearFilterAsync();
}
}
private async Task ClearFilterAsync(FilterMenuTemplateContext filterContext)
{
await filterContext.ClearFilterAsync();
}
//obtain filter lists data from the data source to show all options
async Task GetTeamOptions()
{
if (TeamsList == null) // sample of caching since we always want all distinct options,
//but we don't want to make unnecessary requests
{
TeamsList = await GetNamesFromService();
}
}
async Task<List<TeamNameFilterOption>> GetNamesFromService()
{
await Task.Delay(500);// simulate a real service delay
// this is just one example of getting distinct values from the full data source
// in a real case you'd probably call your data service here instead
// or apply further logic (such as tie the returned data to the data the grid will have according to your business logic)
List<TeamNameFilterOption> data = AllGridData.OrderBy(z => z.Team).Select(z => z.Team).
Distinct().Select(t => new TeamNameFilterOption { Team = t }).ToList();
return await Task.FromResult(data);
}
async Task GetNameOptions()
{
if (NameOptions == null)
{
NameOptions = await GetNameOptionsFromService();
}
}
async Task<List<NameFilterOption>> GetNameOptionsFromService()
{
await Task.Delay(500);// simulate a real service delay
List<NameFilterOption> data = AllGridData.OrderBy(z => z.Name).Select(z => z.Name).
Distinct().Select(n => new NameFilterOption { Name = n }).ToList();
return await Task.FromResult(data);
}
#endregion custom-filter-data
async Task OnReadHandler(GridReadEventArgs args)
{
//typical data retrieval for the grid
var filteredData = await AllGridData.ToDataSourceResultAsync(args.Request);
args.Data = filteredData.Data as IEnumerable<Employee>;
args.Total = filteredData.Total;
}
protected override async Task OnInitializedAsync()
{
AllGridData = new List<Employee>();
var rand = new Random();
for (int i = 1; i <= 15; i++)
{
AllGridData.Add(new Employee()
{
EmployeeId = i,
Name = "Employee " + i.ToString(),
Team = "Team " + i % 3,
IsOnLeave = i % 2 == 0
});
}
await GetTeamOptions();
await GetNameOptions();
}
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
public string Team { get; set; }
public bool IsOnLeave { get; set; }
}
// in this sample we use simplified models to fetch less data from the service
// instead of using the full Employee model that has many fields we do not need for the filters
public class TeamNameFilterOption
{
public string Team { get; set; }
}
public class NameFilterOption
{
public string Name { get; set; }
}
}
When using the TelerikCheckBoxListFilter component in a FilterMenuTemplate, it does render a checkbox with a blank label, but selecting it does not generate a filter descriptor.
For reference, the built-in CheckBoxList filtering correctly filters null values.
When filtering or editing a Grid with enum data, the Name property of their Display parameter is respected.
However, in the initial view mode of the Grid the Name property is not applied and the enum values are rendered regardless of whether or not their Display parameter has a Name property defined.
==========
ADMIN EDIT
==========
In the meantime, a workaround you might try is to create a custom method to check whether Display attribute is defined and get and display its Name property, otherwise display the Enum's member name.
You can then use a Template for the column that uses enum data, cast its context to the model you are using and invoke the method on the field containing the enum. The sample below demonstrates how you can achieve this.
@using System.ComponentModel.DataAnnotations
@using System.Reflection
<TelerikGrid Data=@MyData EditMode="@GridEditMode.Inline" Pageable="true" Height="500px"
OnUpdate="@UpdateHandler" FilterMode="@GridFilterMode.FilterRow">
<GridColumns>
<GridColumn Field=@nameof(SampleData.ID) Editable="false" Title="ID" />
<GridColumn Field=@nameof(SampleData.Name) Title="Name" />
<GridColumn Field=@nameof(SampleData.Role) Title="Position">
<Template>
@{
var currentEmployee = context as SampleData;
var currentRole = GetDisplayName(currentEmployee.Role);
}
@currentRole
</Template>
</GridColumn>
<GridCommandColumn>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
@code {
//custom method to check whether Display attribute is defined and get and display its Name property, otherwise display the Enum's member name
public string GetDisplayName(Enum val)
{
return val.GetType()
.GetMember(val.ToString())
.FirstOrDefault()
?.GetCustomAttribute<DisplayAttribute>(false)
?.Name
?? val.ToString();
}
public void UpdateHandler(GridCommandEventArgs args)
{
SampleData item = (SampleData)args.Item;
//update the view-model
var index = MyData.FindIndex(i => i.ID == item.ID);
if (index != -1)
{
MyData[index] = item;
}
//perform actual data source operations here
}
//model and dummy data generation
public class SampleData
{
public int ID { get; set; }
public string Name { get; set; }
public Role Role { get; set; }
}
public enum Role
{
[Display(Name = "Manager")]
ManagerRole,
[Display(Name = "Employee")]
EmployeeRole,
[Display(Name = "Contractor")]
ContractorRole
}
public List<SampleData> MyData { get; set; }
protected override void OnInitialized()
{
MyData = new List<SampleData>();
for (int i = 0; i < 50; i++)
{
MyData.Add(new SampleData()
{
ID = i,
Name = "name " + i,
Role = (Role)(i % 3) // just some sample to populate initial values for the enum
});
}
}
}
The RadioGroup's FocusAsync() method does not work. To reproduce, run this example and press the button: https://docs.telerik.com/blazor-ui/components/radiogroup/overview#radiogroup-reference-and-methods
===
A possible workaround is to use JavaScript to focus the first or the selected <input> element:
@inject IJSRuntime js
<TelerikButton OnClick="@FocusRadioGroup">Focus RadioGroup</TelerikButton>
<TelerikRadioGroup Data="@RadioGroupData"
Class="my-radiogroup"
@bind-Value="@RadioGroupValue"
ValueField="@nameof(ListItem.Id)"
TextField="@nameof(ListItem.Text)">
</TelerikRadioGroup>
@* Move JavaScript code to a separate JS file in production *@
<script suppress-error="BL9992">function focusRadio(RadioGroupValue) {
var mrg = RadioGroupValue == null ?
document.querySelector(".my-radiogroup .k-radio-list-item input") :
document.querySelector(`.my-radiogroup .k-radio-list-item input[value='${RadioGroupValue}']`);
if (mrg) {
mrg.focus()
}
}</script>
@code{
private int? RadioGroupValue { get; set; }
List<ListItem> RadioGroupData { get; set; } = new List<ListItem>() {
new ListItem { Id = 1, Text = "Foo" },
new ListItem { Id = 2, Text = "Bar" },
new ListItem { Id = 3, Text = "Baz" }
};
private async Task FocusRadioGroup()
{
await Task.Delay(1);
await js.InvokeVoidAsync("focusRadio", RadioGroupValue);
}
public class ListItem
{
public int Id { get; set; }
public string Text { get; set; } = string.Empty;
}
}
The AnchorSelector parameter of the Popover should support runtime changing. Currently, to change the parameter value, the app must recreate the component by removing it temporarily from the page:
Using Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.11.0
Trying to create a new Telerik for Blazor project using Telerik C# Blazor Application Template.
Visual Studio freezes after I Name the project and click create. Only way to exit out of Visual Studio is to kill it through task manager.
Trying your project walk through for Blazor, RpsTrackingBlazor, After I add the nuget packages and try to add the using statement to _imports.razor as in the tutorial I get the error that the type or namespace name telerik could not be found.
Your project uses <TargetFramework>netcoreapp3.1</TargetFramework>
I also tried framework net8.0
Hi,
starting with version 6.0, dialogs used together with loading indicator are at wrong z-index order.
- None of hotfixes with "delay" helped.
- users are stucked and cant confirm anything
How to replicate
Click on "Show Confirm with loading indicator". Loading animation should be at BACK of confirm dialog(as at older versions, prior 6.0)
https://blazorrepl.telerik.com/GeOfQMkt56AMkdof43
Steps to reproduce:
Expected: Both the parent "Documents" and its 4 children should be checked.
Actual: Only the 4 children are checked; the parent remains unchecked.
This only happens when all children are checked. However, if not all children items are checked, the parent will also be checked.
A REPL example to reproduce the issue is:
https://blazorrepl.telerik.com/mIuTdbuT08QWQoY319
The error is:
Programmatic changes to the Overflow parameter of ToolBar items do not take effect until the user resizes the browser window. This is because the internal item collections are updated only during initialization and window resize.
A possible workaround is to recreate the ToolBar items when making changes to them.
Test Page with the workaround:
<TelerikToolBar Adaptive="true">
@if (ShouldRenderToolBarItems)
{
<ToolBarButton>Foo</ToolBarButton>
<ToolBarButton Overflow="@PrintOverflow">Print</ToolBarButton>
<ToolBarButton>Bar</ToolBarButton>
}
</TelerikToolBar>
<TelerikButton OnClick="TogglePrint">Toggle Print</TelerikButton>
@code {
private ToolBarButton printButton = default!;
private TelerikToolBar toolbar = default!;
private ToolBarItemOverflow PrintOverflow { get; set; } = ToolBarItemOverflow.Auto;
private bool ShouldRenderToolBar { get; set; } = true;
private bool ShouldRenderToolBarItems { get; set; } = true;
private async Task TogglePrint()
{
// Uncomment to enable the workaround
//ShouldRenderToolBarItems = false;
await Task.Delay(1);
if (PrintOverflow == ToolBarItemOverflow.Always)
{
PrintOverflow = ToolBarItemOverflow.Auto;
}
else
{
PrintOverflow = ToolBarItemOverflow.Always;
}
ShouldRenderToolBarItems = true;
}
}
Hi Telerik Team,
when using the (currently) latest versions of VS (17.11.0) and Blazor 8.0.8 runtimes (and custom css theme version 8.2.0) I get the following error when running my project in debug mode:
TypeError: Cannot read properties of null (reading 'classList')
Stapelüberwachung:
> at e.addClass (https://localhost:7038/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1122923)
> at v.resetCallout (https://localhost:7038/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1372516)
> at v.adjustCalloutPosition (https://localhost:7038/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1372355)
> at e.invokeComponentMethod (https://localhost:7038/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1112736)
> at https://localhost:7038/_framework/blazor.webassembly.js:1:2878
> at new Promise (<anonymous>)
> at b.beginInvokeJSFromDotNet (https://localhost:7038/_framework/blazor.webassembly.js:1:2835)
> at Object.vn [as invokeJSJson] (https://localhost:7038/_framework/blazor.webassembly.js:1:58849)
> at https://localhost:7038/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:178428
> at Ll (https://localhost:7038/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:179262)
It looks like the problem has something to do with a function that wants to set the css "k-callout-e" class to some object.
The problem appears in js when e is null in the following method:
e.classList.add(t)
In this case e = null and t = "k-callout-e". It seems there's no null check for e and VS 2022 reports the problem.
The debugger in VS cannot be disabled for js content as it seems it's the same debugger for Blazor itself.
When hitting F5 to continue multiple times the projects keeps running until it hits the same problem again.
In my project I added a single "TelerikTooltip" component for Tooltips. I tried disabling it but still the same problem.
Maybe the js code is used for some other component.
If you need more information just let me know.
Regards,
Tom