Telerik Forums
UI for Blazor Forum
1 answer
520 views

Hi,

I'm attempting to do something that is probably dumb/unsupported. We have a paginated grid in our UI that we want to include a joined model in.

Example:


public class Item
{
   [Key]
   public Guid ItemId{ get; set; } = Guid.NewGuid();
   public Guid? LatestLogId { get; set; }
}

public class ItemLog
{
   [Key] 
   public Guid ItemLogId{ get; set; }
   
   public Guid ItemId{ get; set; }
   [ForeignKey("ItemId")]
   public Item? Item { get; set; }

   [MaxLength(250)] public string Message { get; set; } = null!;
}


We use 'LatestLogId' in order to know what ItemLog to 'include' in the results in the UI

I'm trying to project it into a Dto that includes both the Item and the LatestLog but running into some trouble calling 'ToDataSourceResultAsync' with that IQueryable<Dto>


 public async Task<DataSourceResult> GetItemReportPage(DataSourceRequest pageRequest, Guid staffId,
        bool includeAll = false)
    {
            var baseQuery = _appContext.Items
                .AsQueryable();
            if (!includeAll)
            {
                baseQuery = baseQuery.Where(x => x.CreatedBy== staffId);
            }
                var query= baseQuery.Select(item => new ItemWithLatestLogDto
                    {
                        LatestLog = _appContext.ItemLogs.FirstOrDefault(x => x.ItemLogId== request.LatestLogId) 
                    })
                    .AsNoTracking();


        var dataSourceResult = await query.ToDataSourceResultAsync(pageRequest);
        return dataSourceResult;
    }


When calling that I get an error that is something like this:


System.InvalidOperationException: The LINQ expression 'DbSet<Item>()
    .Where(n => n.CreatedById== __staffId_0)
    .OrderByDescending(n => new ItemWithLatestLogDto{ LatestLog = DbSet<ItemLog>()
            .Where(r => (Guid?)r.ItemLogId== n.LatestLogId)
            .FirstOrDefault() }
    .CreatedDateTimeUtc)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.<VisitMethodCall>g__CheckTranslated|15_0(ShapedQueryExpression translated, <>c__DisplayClass15_0&)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.IEnumerable.GetEnumerator()
   at Telerik.DataSource.Extensions.QueryableExtensions.Execute[TModel,TResult](IQueryable source, Func`2 selector)
   at Telerik.DataSource.Extensions.QueryableExtensions.CreateDataSourceResult[TModel,TResult](IQueryable queryable, DataSourceRequest request, Func`2 selector)
   at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request)

The Dto looks like this:

public class ItemWithLatestLogDto: Item
{
    public ItemLog? LatestLog { get; set; } 
 
    public NewFileRequestWithLatestLogDto()
    {
    }
}



Is this a use-case supported by the method or do I need to find a different way of accomplishing this?

Thanks!



Svetoslav Dimitrov
Telerik team
 answered on 11 Mar 2024
1 answer
375 views
I need to know when the grid has been rendered. Is there a way?
Hristian Stefanov
Telerik team
 answered on 11 Mar 2024
2 answers
351 views

Hy,

In my application I had to insert the localization with the default Italian language.

I followed the points explained in this link step by step: Blazor Localization - Telerik UI for Blazor

Inside my application I therefore have a Resources folder with the following files inside:
TelerikMessages.resx and TelerikMessages.it-IT.resx (set as default on Program.cs).

My problem is the following: in debug the localization for the DateTimePicker or NumericTextBox components works correctly showing me the date and number formats in Italian with the related translated texts.

However, once I insert my application into a docker container, the localization seems to have no effect, showing both components in English language and format.

My Resources Folder:

However, localization for the Grid component works correctly in both cases.

Attached is the behavior of the date picker in debug mode and inside a docker container.

Can anyone give me a solution without using the Format property of the components but using localization? My application is in Dotnet 8

Thanks.

Marco
Top achievements
Rank 3
Iron
Iron
Iron
 answered on 11 Mar 2024
1 answer
174 views

When I use the ColumnSpan property on a floating label, the label itself will grow to the number of columns, but the content of the label will always get the size of the column the floating label is int.

Below is the code I've used:


@page "/gridLayout"

<TelerikGridLayout>
    <GridLayoutColumns>
        <GridLayoutColumn Width="200"/>
        <GridLayoutColumn Width="200"/>
        <GridLayoutColumn Width="200"/>
        <GridLayoutColumn Width="200"/>
    </GridLayoutColumns>

    <GridLayoutItems>
        <GridLayoutItem Column="1"
                        Row="1"
                        ColumnSpan="3">
            <TelerikTextBox Title="Filial" />
        </GridLayoutItem>
        <GridLayoutItem Column="1"
                        Row="2"
                        ColumnSpan="3">
            <TelerikFloatingLabel Text="Pessoa">
                <TelerikTextBox />
            </TelerikFloatingLabel>
        </GridLayoutItem>
    </GridLayoutItems>
</TelerikGridLayout>

This is how it's rendered:

 

Diego Modolo
Top achievements
Rank 1
Iron
Iron
 answered on 08 Mar 2024
1 answer
173 views

Hello Guys, i got the License for Blazor Application, 

I'm using Server Side at .net 6 and i put the css and js on _Layout :

<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" />

<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>

On nuget i got the full version as well,

But i keep receiveng the trial version message when i use PDF Viewer, am i missing anything else? 

 

Dimo
Telerik team
 answered on 08 Mar 2024
1 answer
246 views
Looking for a solution to expand the previous expanded DetailTemplate after a grid rebind.  The data for the grid is updated from a click event within the DetailTemplate and need the grid updated and the expanded row to either stay expanded or re-expand after the grid rebind.
Tsvetomir
Telerik team
 answered on 07 Mar 2024
1 answer
101 views

Hi everyone

When using a translated ListView, the page size selector behaves weird.

When the dropdown is opened, the correct text ("Alle") gets displayed. But when the dropdown is closed, the english text is shown,

Any ideas?

Thanks alot and have a nice day

Dimo
Telerik team
 answered on 07 Mar 2024
1 answer
144 views

I'm having trouble finding the cause of why the display has changed and the paging control is cutting off the value.  I can't see the difference from the Telerik doc examples.

 

or ...

The width of the browser window or resolution doesn't have any effect.

We are using the "_content/Telerik.UI.for.Blazor/css/kendo-theme-bootstrap/all.css".

 

 

Dimo
Telerik team
 updated answer on 07 Mar 2024
0 answers
111 views

On the map component when zoomed in there are labels for points of interest (businesses/airports/hotels/restaurants/etc..)

 

Is it possible to capture these when a user clicks on an item? I know I can capture the lat/long of a click but can I get the details of the point of interest?

Matt
Top achievements
Rank 1
Iron
 asked on 06 Mar 2024
0 answers
197 views
As of now, the OnChange event of the AutoComplete component is triggered upon pressing the Enter key or losing focus of the input. In order to only produces changes upon pressing Enter, I use the OnBlur event to change specific boolean values (e.g isInputFocused) so as to modify the behaviour of OnChange conditionally. Is OnBlur always triggered before OnChange? In the future, will a new event be added to the TelerikAutoComplete component which is triggered only upon pressing the Enter key?
Ricardo
Top achievements
Rank 1
Iron
 asked on 04 Mar 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?