I'm currently migrating a project from ASP.NET MVC to ASP.NET MVC Core.
In the server code I'm using a DataTable from the database which is converted to a DataSourceResult with ToDataSourceResult.
It worked fine in the ASP.NET MVC version, but the same code in the ASP.NET MVC Core version throws an exception when using aggregate functions.
System.InvalidOperationException: 'No generic method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. '
1. Create tree model from class:
public class TreeNodeViewModel
{
public string NodeName { get; set; }
public IEnumerable<TreeNodeViewModel> Children { get; set; }
public bool Expanded { get; set; }
public string Color { get; set; }
public string IconClass { get; set; }
}
2. Pass this tree for rendering to the component "TelerikTreeView".
3. An error comes out:
2020-12-03T09:44:15.312Z] Error: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Blazor.Data.TelerikTreeViewDataSource.GetFlatItems(IEnumerable`1 tree, List`1 result)
at Telerik.Blazor.Data.TelerikTreeViewDataSource.GetFlatItems(IEnumerable`1 tree, List`1 result)
at Telerik.Blazor.Data.TelerikTreeViewDataSource.GetFlatItems(IEnumerable`1 tree, List`1 result)
at Telerik.Blazor.Data.TelerikTreeViewDataSource.GetFlatItems(IEnumerable`1 tree, List`1 result)
at Telerik.Blazor.Data.TelerikTreeViewDataSource.FlattenTree()
at Telerik.Blazor.Data.TelerikTreeViewDataSource.InitData(IEnumerable`1 sourceData)
at Telerik.Blazor.Data.TelerikTreeViewDataSource.ProcessData(IEnumerable data)
at Telerik.Blazor.Components.TelerikTreeView.ProcessDataInternal()
at Telerik.Blazor.Components.Common.DataBoundComponent`1.ProcessDataAsync()
at Telerik.Blazor.Components.TelerikTreeView.OnAfterRenderAsync(Boolean firstRender)
--- End of inner exception stack trace ---
Note: This problem is due to the fact that there are no children in the last node of the tree and IEnumerable Children == NULL. Method "GetFlatItems" in version 2.18.0 it had a NULL check, in version 2.20.0 it is not.
build.config showing in project as a linked file......
linked path: :\Users\User\.nuget\packages\telerik.ui.for.blazor\2.15.0\contentFiles\any\netstandard2.1\build.config
content:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="LocalNuget" value="D:\Jenkins\Workspace\Blazor-Package\nugets" /> </packageSources> </configuration>
---
ADMIN EDIT
The following should let the multiselect render above the custom yellow element, but it does not. A workaround is available as the second CSS snippet that you can uncomment.
<style>
/*should work but does not*/
.high-zindex {
z-index: 124;/*note how this is higher than the z-index of the div element, and is higher than the default z-index of the component*/
}
/*workaround*/
.k-animation-container {
z-index: 15000;
}
</style>
<div style="position: absolute; z-index: 123; width: 600px; height: 200px; background: yellow;">
<TelerikMultiSelect Data="@Countries"
@bind-Value="@Values"
Placeholder="Enter Balkan country, e.g., Bulgaria"
ClearButton="true" AutoClose="false"
PopupClass="high-zindex">
</TelerikMultiSelect>
</div>
@code {
List<string> Countries { get; set; } = new List<string>();
List<string> Values { get; set; } = new List<string>();
protected override void OnInitialized()
{
Countries.Add("Albania");
Countries.Add("Bosnia & Herzegovina");
Countries.Add("Bulgaria");
Countries.Add("Croatia");
Countries.Add("Kosovo");
Countries.Add("North Macedonia");
Countries.Add("Montenegro");
Countries.Add("Serbia");
Countries.Add("Slovenia");
base.OnInitialized();
}
}
---
Hi!
Im using a Grid component InCell Editing the OnDelete, OnUpdate handlers are working fine but OnCreate handler its not working. By the way im using a service to manage the CRUD operations as follows
Page Component
@page "/districts"
@using MVC.Services
@using MVC.Models
@using System.ComponentModel.DataAnnotations
@inject IDistrictService DistrictService
<h3>Districts</h3>
<TelerikGrid Data="@district" Sortable="true" EditMode="@GridEditMode.Incell"
Height="500px"
Pageable="true" PageSize=@PageSize
OnUpdate=@UpdateItem OnDelete=@DeleteItem OnCreate=@CreateItem OnCancel="@OnCancelHandler">
<GridToolBar>
<GridCommandButton Command="Add" Icon="add">Add District</GridCommandButton>
</GridToolBar>
<GridColumns>
<GridColumn Field="@(nameof(District.Id))" Editable="false" />
<GridColumn Field="@(nameof(District.Description))" Title="Description" />
<GridColumn Field="@(nameof(District.EnableApprovalWorkflow))" Title="Enable Approval Workflow" />
<GridCommandColumn>
<GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
@code {
int PageSize = 15;
IEnumerable<District> district;
protected override async Task OnInitializedAsync()
{
await GetGridData();
}
async Task GetGridData()
{
district = await DistrictService.DistrictList();
}
async Task CreateItem(GridCommandEventArgs args)
{
District item = (District)args.Item;
await DistrictService.DistrictInsert(item);
await GetGridData();
}
void OnCancelHandler(GridCommandEventArgs args)
{
District item = (District)args.Item;
}
async Task DeleteItem(GridCommandEventArgs args)
{
District item = (District)args.Item;
await DistrictService.DistrictDelete(item.Id);
await GetGridData();
}
async Task UpdateItem(GridCommandEventArgs args)
{
District item = (District)args.Item;
await DistrictService.DistrictUpdate(item);
await GetGridData();
}
}
Service Logic
using Dapper;
using Microsoft.Data.SqlClient;
using MVC.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MVC.Services
{
public class DistrictService : IDistrictService
{
private readonly SqlConnectionConfiguration _configuration;
public DistrictService(SqlConnectionConfiguration configuration)
{
_configuration = configuration;
}
public async Task<bool> DistrictInsert(District district)
{
using (var conn = new SqlConnection(_configuration.Value))
{
var parameters = new DynamicParameters();
parameters.Add("Description", district.Description, DbType.String);
parameters.Add("EnableApprovalWorkflow", district.EnableApprovalWorkflow, DbType.Boolean);
await conn.ExecuteAsync("spLookupDistrict_Insert", parameters, commandType: CommandType.StoredProcedure);
}
return true;
}
public async Task<IEnumerable<District>> DistrictList()
{
IEnumerable<District> districts;
using (var conn = new SqlConnection(_configuration.Value))
{
districts = await conn.QueryAsync<District>("spLookupDistrict_List", commandType: CommandType.StoredProcedure);
}
return districts;
}
public async Task<IEnumerable<District>> DistrictSearch(string @Param)
{
var parameters = new DynamicParameters();
parameters.Add("@Param", Param, DbType.String);
IEnumerable<District> districts;
using (var conn = new SqlConnection(_configuration.Value))
{
districts = await conn.QueryAsync<District>("spLookupDistrict_Search", parameters, commandType: CommandType.StoredProcedure);
}
return districts;
}
public async Task<District> District_GetOne(int @Id)
{
District district = new District();
var parameters = new DynamicParameters();
parameters.Add("@Id", Id, DbType.Int32);
using (var conn = new SqlConnection(_configuration.Value))
{
district = await conn.QueryFirstOrDefaultAsync<District>("spLookupDistrict_GetOne", parameters, commandType: CommandType.StoredProcedure);
}
return district;
}
public async Task<bool> DistrictUpdate(District district)
{
using (var conn = new SqlConnection(_configuration.Value))
{
var parameters = new DynamicParameters();
parameters.Add("Id", district.Id, DbType.Int32);
parameters.Add("Description", district.Description, DbType.String);
parameters.Add("EnableApprovalWorkflow", district.EnableApprovalWorkflow, DbType.Boolean);
await conn.ExecuteAsync("spLookupDistrict_Update", parameters, commandType: CommandType.StoredProcedure);
}
return true;
}
public async Task<bool> DistrictDelete(int Id)
{
var parameters = new DynamicParameters();
parameters.Add("@Id", Id, DbType.Int32);
using (var conn = new SqlConnection(_configuration.Value))
{
await conn.ExecuteAsync("spLookupDistrict_Delete", parameters, commandType: CommandType.StoredProcedure);
}
return true;
}
}
}
When re-visiting a drop down each selected option is visually indicated, but not to a screen reader user. E.g.:
Figure: Selected options are highlighted but this is not indicated to a screen reader
Blazor first steps bug in documentation, Primary="true" gives an error.
https://docs.telerik.com/blazor-ui/getting-started/server-blazor
Step 3 - Add a Telerik Component to a View
<TelerikButton OnClick="@SayHelloHandler" Primary="true">Say Hello</TelerikButton>
Primary = "true" gives an error with version 3, sb different for .net 6 and use ThemeColor
Hi. VS 2022 version 17.2.4, C#, Windows 11
I thought I'd have a look at blazor and selected the Telerik version in the new projects window and ran through the wizard.
I selected the dashboard look, .net 6, teleric UI for blazor 3.4.0 (Dev) and to enable localization, which is what I assume to be the cause of the following error message. There were no other hints and as I've never tried blazor or telerik for
blazor I don't know if there's anything missing from the solution. If I ran another wizard without localization there was no error.
An error occurred while running the wizard.
Error executing custom action Telerik.Blazor.VSX.Actions.CopyBlazorLocalizationResourcesAction: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Blazor.VSX.Actions.CopyBlazorLocalizationResourcesAction.Execute(WizardContext wizardContext, IPropertyDataDictionary arguments, IProjectWrap project)
at Telerik.VSX.WizardEngine.ActionManager.ExecActions()
Hello,
I am using the TelerikSkeleton component for Blazor and noticed the pulse and wave animations are not working. It seems animation also does not work in your examples here, while it works in Telerik REPL (that's where I could identify the issue)
For my application, I made my custom theme with ThemeBuilder and then imported it into my project as instructed. Going through the css file, I found where the bug is:
How it was:
.k-skeleton-pulse .k-skeleton {
animation:k-skeleton-pulse 1.5s ease-in-out .5s infinite
}
After my changes:
.k-skeleton-pulse.k-skeleton { animation:k-skeleton-pulse 1.5s ease-in-out .5s infinite }
The only thing I did was I removed the space between the two classes and now it works.
Note: I selected "WebAssembly" as application type, but I am actually using it for both a Razor class library and a .NET MAUI Blazor application.
https://demos.telerik.com/blazor-ui/form/templates
When you edit in Telerik Repl, you get a warning message:
What was weird though, is when I ran it from directly from the link in the documentation, I didn't get an error. I made one small change to the code (swapped line 54 and 55 (just seeing if I could change the rendering order, which I can) and then I saw this warning. But any change to the code generates the warning.
Peter
My grid bind to ExpandoObjects, and I would like to implement a Group Header.
So I referenced these two documents
https://docs.telerik.com/blazor-ui/knowledge-base/grid-binding-to-expando-object
https://docs.telerik.com/blazor-ui/components/grid/columns/multi-column-headers
From the first document, it make sense to me that we need to set FieldType for each column that binds to ExpandoObject, but it seems this restriction also applies to the group header column, which does not make sense.
Foe example:
<TelerikGrid Data="@GridData"
Pageable="true"
Sortable="true"
FilterMode="@GridFilterMode.FilterRow">
<GridColumns>
<GridColumn Title="Test Group Header">
<Columns>
<GridColumn Field="PropertyInt" Title="Int Column" FieldType="@typeof(int)" />
<GridColumn Field="PropertyString" Title="String Column" FieldType="@typeof(string)" />
<GridColumn Field="PropertyDate" Title="DateTime Column" FieldType="@typeof(DateTime)" />
</Columns>
</GridColumn>
</GridColumns>
</TelerikGrid>
I get error:
I need to set FieldType on the "Test Group Header" column to an arbitrary value to get rid of this error.
Using the new Grid grouping feature in 1.6, the Grouping button and the group header row both use the field name of the group column, rather than the title. This is visible in the animated demo, where a column titled "On Vacation" becomes "IsOnLeave" once it is used as a group name.
I expect this is already known and slated to be fixed, but there aren't any grouping issues at all in the public tracker, so just in case...
Hi
I don't understand the text in this yellow info box: "You can define a key for zooming only selection zooming is configured." Is there a word missing?
https://docs.telerik.com/blazor-ui/components/chart/pan-and-zoom/zoom#specifying-a-key-for-zooming
According to the doc (https://docs.telerik.com/blazor-ui/components/grid/columns/width),
"When all column widths are explicitly set and the cumulative column width is greater than the available Grid width, a horizontal scrollbar appears and all set column widths are respected."
I have a grid with a width of 1500px and a cumulative column width of 1750 pixels:
<TelerikGrid Data="@datos"The horizontal scroll bar appears all right, but the column widths are not respected. As shown in the image, the columns on the right are squeezed
Any clues?
Thanks in advance
The https://nuget.telerik.com/nuget/ is erroring when trying to restore the packages, it's currently breaking our main pipeline.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='runtime.native.System.Net.Http'&semVerLevel=2.0.0'. Response status code does not indicate success: 500 (Internal Server Error). GET https://nuget.telerik.com/nuget/FindPackagesById()?id='runtime.native.System.Net.Http'&semVerLevel=2.0.0 InternalServerError https://nuget.telerik.com/nuget/FindPackagesById()?id='Microsoft.Extensions.Hosting.Abstractions'&semVerLevel=2.0.0 290ms InternalServerError https://nuget.telerik.com/nuget/FindPackagesById()?id='Telerik.UI.for.Blazor'&semVerLevel=2.0.0 401ms InternalServerError https://nuget.telerik.com/nuget/FindPackagesById()?id='System.ServiceModel.Primitives'&semVerLevel=2.0.0 401ms ##[error]The nuget command failed with exit code(1) and error(Failed to retrieve information about 'Telerik.UI.for.Blazor' from remote source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='Telerik.UI.for.Blazor'&semVerLevel=2.0.0'. Response status code does not indicate success: 500 (Internal Server Error).
Could you help with this?
Hello,
first of all, thank you for relelasing Dialog, it is what we are "simulating" by modal Window on any kind of heavy data editing app,again and again and again :) .
The problem is,
- when you put DropDownList in Dialog, using OnRead async task event, the UI is still "empty". => Iam fiddled with reassigning datasource, changing order of assigning source, nothing helped.
- same dropdownlist scenario inside window, working/displayed as expected.
Steps to reproduce:
1) click on then button to show window by -> async task
2) event OnRead of the dropdownlist is correctly called, data to the IEnumerable<model> is loaded
3) window appear, but DropDownList is empty
4) when you filter by typeing inside DropDownList, OnRead is called and model populated, but GUI is still empty
What doesnt worked:
- statechaned, reassign datasource, clear datasource, task delay
What partially worked:
- OnRead=> async Task changed to just: OnRead=> Task
Thanks for info what should be made done else.
Stripped sample:
<TelerikButton @onclick="@(() => ParamEd(4444, null))">open window or dialog</TelerikButton>
<TelerikWindow Modal="true" @bind-Visible="@ShowEditWindow" Draggable="true">
<WindowTitle>
<strong>@ShowEditWindowCaption</strong>
</WindowTitle>
<WindowContent>
<TelerikDropDownList @bind-Value="@CurrentEdit.ValTxt"
ScrollMode="@DropDownScrollMode.Virtual"
Data="@CurrentEdit.ComboSource"
OnRead="@ReadComboData"
ItemHeight="30"
TotalCount="@Paging.CNT"
PageSize="14"
PopupHeight="400px"
TextField="Nazev1"
ValueField="KeyVal"
Filterable="true"
FilterOperator="StringFilterOperator.Contains">
</TelerikDropDownList>
....
vs
<TelerikDialog @bind -Visible="@ShowEditWindow" Title="@ShowEditWindowCaption" CloseOnOverlayClick="false">
<DialogContent>
<TelerikDropDownList @bind-Value="@CurrentEdit.ValTxt"
ScrollMode="@DropDownScrollMode.Virtual"
Data="@CurrentEdit.ComboSource"
OnRead="@ReadComboData"
ItemHeight="30"
TotalCount="@Paging.CNT"
PageSize="14"
PopupHeight="400px"
TextField="Nazev1"
ValueField="KeyVal"
Filterable="true"
FilterOperator="StringFilterOperator.Contains">
</TelerikDropDownList>
....
@code{
//clicked on the button to show window/dialog:
async Task ParamEd(int xtyp, object it)
{
await Task.Delay(500);//await load captions... and THEN open window:
ShowEditWindowCaption = "window title";
ShowEditWindow = true;
}
async Task ReadComboData(DropDownListReadEventArgs e)
{
try
{
var r = await readDBDATA...
//CurrentEdit.ComboSource = new List<EdBase>();
//CurrentEdit.ComboSource = null;
//CurrentEdit.ComboSource = new IEnumerable<EdBase>(r);
//CurrentEdit.ComboSource = await ReadDBDATA
CurrentEdit.ComboSource = r;
Paging.CNT = p.Get<int>("CNT");
/*
//!! HOTFIX FROM ANOTHER BUG(show selected data) - ReAssign data(but id doesnt impact result):
string v = CurrentEdit.ValTxt;
int? i= CurrentEdit.ValInt;
CurrentEdit.ValTxt = string.Empty;
CurrentEdit.ValInt = null;
StateHasChanged();
//await InvokeAsync(() => StateHasChanged());
CurrentEdit.ValTxt = v;
CurrentEdit.ValInt = i;
//CurrentEdit.ValTxt = CurrentEdit.ValTxt;
//StateHasChanged();
*/
}
catch (Exception ex)
{
Notification.ShowSQLErr(ex.Message);
}
}
//PARTIALLY WORKING, but not filtering:
Task ReadComboData(DropDownListReadEventArgs e)
{
try
{
var r = readDBDATA...
CurrentEdit.ComboSource = r;
Paging.CNT = p.Get<int>("CNT");
}
catch (Exception ex)
{
Notification.ShowSQLErr(ex.Message);
}
}
}