Hi!
I have the following setup:
CsHtml:
<div class="row mt-3">
<div class="col-lg-4">
@(Html.Kendo().DropDownListFor(m => m.CategoryHeadId)
.Size(ComponentSize.Medium)
.Rounded(Rounded.Medium)
.FillMode(FillMode.Solid)
.OptionLabel("Select head category...")
.HtmlAttributes(new { style = "width: 100%" })
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetLookupCategoriesHead", "Api");
});
})
)
</div>
<div class="col-lg-4">
@(Html.Kendo().DropDownListFor(m => m.CategoryMainId)
.Size(ComponentSize.Medium)
.Rounded(Rounded.Medium)
.FillMode(FillMode.Solid)
.OptionLabel("Select main category...")
.HtmlAttributes(new { style = "width: 100%" })
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetLookupCategoriesMain", "Api")
.Data("filterMainCategories");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("CategoryHeadId")
)
</div>
<div class="col-lg-4">
@(Html.Kendo().DropDownListFor(m => m.CategorySubId)
.Size(ComponentSize.Medium)
.Rounded(Rounded.Medium)
.FillMode(FillMode.Solid)
.OptionLabel("Select sub-category...")
.HtmlAttributes(new { style = "width: 100%" })
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetLookupCategoriesSub", "Api")
.Data("filterSubCategories");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("CategoryMainId")
)
</div>
</div>
Script:
@section Scripts {
<script>
function filterMainCategories() {
return {
headId: $("#CategoryHeadId").val()
};
}
function filterSubCategories() {
return {
headId: $("#CategoryHeadId").val(),
mainId: $("#CategoryMainId").val()
};
}
</script>
}
Controller:
public async Task<JsonResult> GetLookupCategoriesHead()
{
var result = await serviceLookUps.GetAllCategoriesHeadAsync();
return new JsonResult(result);
}
public async Task<JsonResult> GetLookupCategoriesMain(int headId)
{
var result = await serviceLookUps.GetAllCategoriesMainAsync(headId);
return new JsonResult(result);
}
public async Task<JsonResult> GetLookupCategoriesSub(int headId, int mainId)
{
var result = await serviceLookUps.GetAllCategoriesSubAsync(headId, mainId);
return new JsonResult(result);
}
Model:
[DebuggerDisplay($"{nameof(Id)}: {{{nameof(Id)},nq}}, {nameof(Name)}: {{{nameof(Name)}}}, {nameof(Active)}: {{{nameof(Active)}}}")]
public class LookupCategoryHeadModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public bool Active { get; set; }
}
[DebuggerDisplay($"{nameof(Id)}: {{{nameof(Id)},nq}}, {nameof(Name)}: {{{nameof(Name)}}}, {nameof(Active)}: {{{nameof(Active)}}}")]
public class LookupCategoryMainModel
{
public int Id { get; set; }
public int HeadId { get; set; }
public string Name { get; set; } = string.Empty;
public bool Active { get; set; }
}
[DebuggerDisplay($"{nameof(Id)}: {{{nameof(Id)},nq}}, {nameof(Name)}: {{{nameof(Name)}}}, {nameof(Active)}: {{{nameof(Active)}}}")]
public class LookupCategorySubModel
{
public int Id { get; set; }
public int HeadId { get; set; }
public int MainId { get; set; }
public string Name { get; set; } = string.Empty;
public bool Active { get; set; }
}
I have tested the API methods separately through tests and ensured they are returning values. The only issue is, when I make a selection in the second dropdown, on the API, the second parameter is received as 0 instead of a correct selected value. This doesn't cause any console errors so the UI continues to work. I can cascade from dropdown one to dropdown two but dropdown two sends a 0 for mainId from its filtering operation in filterSubCategories()
In Kendo UI for ASP.Net MVC, you could bind a grid directly to a DataTable, as in
@Html.Kendo().Grid(MyDataTable)...
where MyDataTable is a DataTable object populated with data.
However, using the ASP.Net Core kendo libraries, there is no support for this.
Why not? Are Telerik planning to add this?
Thanks.
So I just created a .NET 6 ASP.NET Core Web App (Razor Pages), added all telerik stuff according to the instructions (NuGet Packages, scripts and styles in _Layout.cshtml, @addTagHelper-s in _ViewImports.cshtml), and HTMLHelpers are rendering correctly. However, when I provide a data source to the DropDownList or ComboBox, all options show up as undefined.
Telerik version: 2022.2.621. Bootstrap: V5.
Here's the code for DropDownList:
Index.cshtml
@page
@model IndexModel
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()
@{
ViewData["Title"] = "Home page";
}
--------------------------------------------------------------------------------
<div class="text-center">
<h1 class="display-4">Welcome</h1>
@(Html.Kendo().DropDownList()
.Name("MyDropdownn")
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width:300px;" })
.AutoBind(false)
.Filter(FilterType.Contains)
.DataSource(ds => ds
.Custom()
.Transport(transport => transport
.Read(r => r
.Url("/Index?handler=Sports")
))
.ServerFiltering(false)
)
)
</div>
Index.cshtml.cs
public JsonResult OnGetSports()
{
var allSports1 = db.Sports.Where(x => x.SportID > 0).Select(x => new DropDownModel
{
Text = x.Name,
Value = x.SportID
}).ToList();
return new JsonResult(allSports1);
}
Proof that the data isn't empty/undefined
DropDownModel.cs (DropDownModel class)
public class DropDownModel
{
public int Value { get; set; }
public string Text { get; set; } = String.Empty;
}
I've tried restarting everything, double-checking everything but nothing helped. Is there a bug with this version of telerik, is something incompatible with ,NET 6 or Bootstrap 5? Or am I doing something wrong?
Hello,
I'm migrating an application from UI For ASP.NET MVC to UI For ASP.NET Core and mobile components are not found, what are the equivalents components of MobileApplication, MobileListView, etc.?
Currently changing projects over to core and the wrapper for context menus appears to be behaving differently:-
We initially add menu items disabled and then enable them as required in JS functions once the applicability of the menu items has been determined.
e.g.
.Items(items => { items.Add().Text("Complete") .HtmlAttributes(new { id = "CompleteID", title = "Complete" }) .Enabled(false); }
function EnableMenu(canComplete) { var menu = $("#@Model.HtmlID").data("kendoContextMenu"); menu.enable("#CompleteID", canComplete); }
This code works fine in the 2020 version of Kendo UI for ASP.NET MVC but not in the ASP.NET Core product.
The work around appears to be just to remove the .Enable(false) when creating the menu items and then the programmatic enabling/disabling works fine.
I couldn't see any documentation that indicated a change in behaviour so wanted to know if this an intentional change or a possible bug?
When using the Boolean editor template with the grid HtmlHelper a label is created in the cell next to the checkbox. This was not always the case. Older versions of kendo excluded the label and only rendered the checkbox. Is there a way to turn off the label and only render the checkbox?
vs
Just got the Trial version this morning and when I added services.AddKendo() to configureservices I get the following error:
System.AggregateException: 'Some services are not able to be constructed
(Error while validating the service descriptor 'ServiceType: Kendo.Mvc.Rendering.IKendoHtmlGenerator
Lifetime: Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator':
Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache'
from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.)'
InvalidOperationException: Error while validating the service descriptor 'ServiceType: Kendo.Mvc.Rendering.IKendoHtmlGenerator
Lifetime: Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator':
Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache'
from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
I have MSDE 2019 Community and my solution/project is set up as an ASP.Net Core 3.1 MVC application
I am using Telerik UI for ASP.NET Core
I have a hierarchical grid with nested child grids where the name is based off the parent grid record ("#gridValue_#=CODE_TABLE_ID#"). Is there an example where only the nested grids are drag and drop sortable and only within the same nested grid? I am not trying to move rows between different nested grids.
Thanks in advance