Telerik Forums
UI for ASP.NET Core Forum
0 answers
130 views

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; }
}
Issue:

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()

DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 04 Jul 2022
1 answer
108 views

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.

Aleksandar
Telerik team
 answered on 01 Jul 2022
1 answer
930 views

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? 

Alexander
Telerik team
 answered on 29 Jun 2022
1 answer
160 views
I have a grid with a custom popup editor.   All of the fields in the popup are automatically set to "Required" when the pop up opens.  There are no annotations in the model that should be causing them to be validated.  I only want a couple of them to be required.  How do I change this behavior?  Where is Kendo getting the idea that every field must be required?
Alexander
Telerik team
 answered on 29 Jun 2022
1 answer
191 views

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.?

Stoyan
Telerik team
 answered on 29 Jun 2022
1 answer
146 views
I'm trying to add a new filterview option to an existing grid filter with six other options that currently work fine. What's different about option 7 is that it needs to use two "or" values to filter the grid with. All the others have only one. Here is the code I've tried (along with one of the working filterview options), but it returns nothing and doesn't even generate any SQL in the console window. There is data in the database for both values.

                //this code works:
                new FilterView("CashR")
                {
                    Filters = new List<DataFilterValue>
                    {
                        new DataFilterValue
                        {
                            Field = nameof(InvoiceVM.InvoiceStatus),
                            Value = "CashR",
                            Operator = ExtendedFilterOperator.IsEqualTo
                        }
                    }
                },
                //this code doesn't work:
                new FilterView("Select Checks")
                {
                    Filters = new List<DataFilterValue>
                    {
                        new DataFilterValue
                        {
                            Field = nameof(InvoiceVM.InvoiceStatus),
                            Value = new string[] { "Verified", "Partial" },
                            Operator = ExtendedFilterOperator.IsInListEqualTo
                        }
                    }
                }
Aleksandar
Telerik team
 answered on 29 Jun 2022
1 answer
116 views

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?

 

Aleksandar
Telerik team
 answered on 29 Jun 2022
2 answers
139 views

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 


Daniel
Top achievements
Rank 1
Iron
 answered on 28 Jun 2022
0 answers
217 views

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

Alan
Top achievements
Rank 1
 asked on 23 Jun 2022
1 answer
118 views

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

Mihaela
Telerik team
 answered on 23 Jun 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?