Telerik Forums
UI for ASP.NET Core Forum
1 answer
301 views
I have a dropdownListFor in a View which is shared within the tabs in the Kendo Tabstrip. Due to cannot override component name when bound to a model expression error I have commented the Name configuration

My Dropdown:
@(Html.Kendo().DropDownListFor(m => m.Country)
       //.Name("city-" + (int)Model.CityID) -- Commented to resolve the error
       .DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetCities", "Home", new { countryID = (int)Model.CountryID})Type(HttpVerbs.Post);
           });
       })
       .OptionLabel("(Please Select))
       .HtmlAttributes(new
       {
           data_bind = "value: cityValue, events: { change: selectedCityChanged }"
       })
)

I have tab strip in which i don't have any issue with the first tab, but for other tabs, the control is not binded properly. Earlier i had the Name to prevent this bind issue.. Need help to fix this issue

I'm using Kendo 2024.3.806 version and ASP.NET Core MVC 8

First Tab:


Second Tab:
Renu
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 12 Oct 2024
0 answers
42 views

Grouping colapsed after the save.

Grouping should be in the same state as before the save 

 

Need help on this issue. will waiting for you response.

Gaurav
Top achievements
Rank 1
 asked on 10 Oct 2024
2 answers
109 views

We have a complicated Kendo Grid with Tag Helper notification. We need to use On Cancel Event within edit operation, by pressing Cancel button. Here is an example (but not Tag Helper)

@(Html.Kendo().Grid<MyModel>()
    .Name("grid")
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Events(events => events.Cancel("onCancel")) // JavaScript event handler
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(m => m.Id))
        .Read(read => read.Action("Read", "Controller"))
        .Update(update => update.Action("Update", "Controller"))
    )
    .Columns(columns =>
    {
        columns.Bound(c => c.Id).Editable(false);
        columns.Bound(c => c.Name);
        columns.Command(command => command.Edit());
    })
)

<script>
    function onCancel(e) {
        console.log("Edit operation was canceled.");
        // e.container is the jQuery object of the edited row or cell.
        // You can use this function to handle custom logic after canceling
    }
</script>
Jens
Top achievements
Rank 1
Iron
 answered on 10 Oct 2024
1 answer
130 views

I have an Editor on a page and there are several Content Security Policy violations in the console. Here is an example:

Refused to apply inline style because it violates the following Content Security Policy directive: "style-src-attr 'unsafe-hashes' 'sha256-aqNNdDLnnrDOnTNdkJpYlAxKVJtLt9CtFLklmInuUAE='". Either the 'unsafe-inline' keyword, a hash ('sha256-5TmCSWsRHHKtNC4AgS23KS5Z9SBqma0xikI6H6iJ1/Y='), or a nonce ('nonce-...') is required to enable inline execution.

Is it possible to use an Editor without adding unsafe-inline to style-src-attr?

Thank you

Ivan Danchev
Telerik team
 answered on 09 Oct 2024
1 answer
77 views
We are enabling strict CSP policies. We have managed to get all components working with the exception of the editor component.  The default was to set the height of the component is to set a style='height:400px; width:300px" This causes the browser to complain about in-line styles. Is there another way to set the height and width of the component? We are getting issues with the setting of in-line styles by the editor. We are currently setting the nonce property on the tag helper for the editor component. Are we missing something?
Mihaela
Telerik team
 answered on 09 Oct 2024
1 answer
63 views

Hello

We are currently working on improving the content security policy header of our application to remove the unsafe-inline and unsafe-eval for the script element.

I am facing some issues when using the Template element with the generated deferred javascript mostly in the grid and I hope someone could help me with that. 

Firstly, I'd like to know if there are some tag helpers that could be used to generate some template. To be more explicit : we use some shared and partial views to render the components in edition mode in our grids. These views are written using tag helpers, for instance we have the following file Views\Shared\EditorTemplates\DateTime.cshtml

@model DateTime

 

<kendo-datetimepicker asp-for="@Model" />

Used in our grids :

column.Bound(User => User.DateCreated).EditorTemplateName("DateTime")

(this is a basic example but we have some more complex views using home made components with taghelper syntax)

I noticed there is a kendo-template tag helper and I would like to know if there is any way to use it in our views, so I could replace my view with the following code and use the EditorTemplateComponentName extension method in my grid :

<kendo-template>
    <kendo-datetimepicker asp-for="@Model" />
</kendo-template>

When I tried to do this I have an exception :

 

Secondly, I noticed an issue when using some kendo elements in editor templates: the javascript rendered in the deferred script file includes the initialisation scripts at the root of the script file. This mainly cause some issues in my pages when some other element has the same names (but I think it can lead to some other issues).

For instance, I have the following column definition in my grid:

<columns>
    <column field="FullName" title="FullName"></column>
    <column field="DateCreated" title="DateCreated">
        <column-editor-template>
            <kendo-datetimepicker name="dateCreated"></kendo-datetimepicker>
        </column-editor-template>
    </column>
</columns>

Then in the kendo-deferred-script javascript file I can see the dateCreated element is inialized at the beginning of the file and in the template function:

 

I'm joining a sample application with both cases to help reproduce the issues.

Is there something I'm doing wrong or any improvement coming in the next versions to fix these issues ?

 

Thanks in advance

Yael

Ivaylo
Telerik team
 answered on 30 Sep 2024
2 answers
1.8K+ views
Hello

I have found an error when the grid is loading data by Ajax with grouping in Asp.net core 6.0 and EF core 6.0 in versión.
I am using the version Telerik.UI.for.AspNet.Core 2022.1.412.

The method Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult is not able to perform the query when DataSourceRequest have included a grouping.

Now, I am going to write down some code to facilating the compressino of issue
The classes in the model uses to load the grid are:

public class TipoVia
{
public Guid Id {get; set;}
public string Codigo {get; set;}
public string Descripcion {get; set;}
}

public class DataContext : DbContext
{
public DbSet<TipoVia> TiposVia { get; set; }
}

In the view the telerik grid is configured with  Ajax the next way:

@Html.Kendo().Grid<TipoVia>.Name("grid")
                    .Columns(columns =>
                    {
                        columns.Bound(p => p.Codigo);
                        columns.Bound(p => p.Descripcion);
}
.DataSource(dataSource =>
                              dataSource.Ajax().PageSize(10)
                              .Read(read => read.Action("GetData", "ControllerTipoVia").Data("obtenerModel").Type(HttpVerbs.Post))
                              );

In the controller the method that It does the loading is:

 public virtual Task<IActionResult> ObtenerPaginaKendo([DataSourceRequest]DataSourceRequest request, TConsultaViewModel viewModelVista)
{
var dsResult = viewModelVista.DataContext.TiposVia.ToDataSourceResult(request);
return Task.Run<IActionResult>(() => Json(dsResult));
} 

Finally, if It is grouped by TipoVia.Codigo the error is the next:

System.InvalidOperationException
HResult=0x80131509
Mensaje = The LINQ expression 'DbSet<TipoVia>()
.OrderBy(c => c.Nombre)
.Select(entidad => new {
Codigo = entidad.Codigo,
Nombre = entidad.Descripcion
}
)
.OrderBy(item => item.Codigo)
.Skip(__p_0)
.Take(__p_1)
.GroupBy(item => item.Codigo)
.OrderBy(group1509060 => group1509060.Key)
.Select(group1509060 => new AggregateFunctionsGroup{
Key = group1509060.Key,
ItemCount = group1509060
.AsQueryable()
.Count(),
HasSubgroups = False,
Member = "Codigo",
Items = group1509060
}
)' could not be translated. Additional information: Translation of 'Select' which contains grouping parameter without composition is not supported. 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.
Origen = Microsoft.EntityFrameworkCore
Seguimiento de la pila:
en Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
en Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
en Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
en Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
en Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
en Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
en Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
en Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
en Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
en Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.IEnumerable.GetEnumerator()
en Kendo.Mvc.Extensions.QueryableExtensions.Execute[TModel,TResult](IQueryable source, Func`2 selector)
en Kendo.Mvc.Extensions.QueryableExtensions.CreateDataSourceResult[TModel,TResult](IQueryable queryable, DataSourceRequest request, ModelStateDictionary modelState, Func`2 selector)
en Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request, ModelStateDictionary modelState)
en Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request)
en GiaBase.AspMvc.Controllers.ConsultaController`5.ObtenerPaginaKendo(DataSourceRequest request, TConsultaViewModel viewModelVista) en C:\Users\U178476\Documents\Repo\comun\codigo\GiaBase\src\GiaBase.AspMvc\Controllers\ConsultaController.cs: línea 419
en Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.<Execute>d__0.MoveNext()
Flavien
Top achievements
Rank 1
Iron
 answered on 29 Sep 2024
0 answers
49 views

Closed

zam
Top achievements
Rank 1
 updated question on 27 Sep 2024
1 answer
254 views
Hi,

I am having a pretty difficult time getting the tabstrip coloring that I am looking for. The end goal I was going for was a dark blue background with white text and the active tab to be shown in a different background color. Here is what I have so far. I am changing the text via inline styling, trying to follow the demo for Tabstrip. I have the class of .k-link defining the background color. This works well and does show the correct styling. However, when adding the red color for the selected tab via the .k-state-active class, it does not override the .k-link class background color. If I do not define the k-link background, the color of the active tab does populate. I assume I am doing this wrong, so what is the best way to change the background color of the tab while still allowing me to change the selected tab color?
Tsvetomila
Telerik team
 answered on 27 Sep 2024
0 answers
53 views
Is there a way to disable sending the token in the form? We would prefer to send it in the header.
Lenny
Top achievements
Rank 1
 asked on 23 Sep 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?