Telerik Forums
UI for ASP.NET Core Forum
3 answers
1.4K+ views

I am Migrating the app from MVC 5 to Core 2.0. We are facing issue with the grid client template as we are unable to use it when we use it along with the editable property. Following is the code.

01.@(Html.Kendo().Grid<PPVR>()
02.                                                .Name("PPVRGird")
03.                                                .Columns(columns =>
04.                                                {
05.                                                    columns.Bound(e => e.id).Hidden();
06.                                                    columns.Bound(c => c.name);
07.                                                    columns.Bound(c => c.quantity);
08.                                                    columns.Bound(c => c.type);
09.                                                    columns.Bound("").ClientTemplate("<div style='text-align:center'><a href='javascript:void(0)' class='k-grid-edit custom-action-button'onclick='customGridEditClick(this)'><img src='/Content/edit.svg' width ='40' height='40'/><br/>Edit</a></div>").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Title("Edit").Width(150);
10.                                                    columns.Bound("").ClientTemplate("<div style='text-align:center'><a href='javascript:void(0)' class='custom-action-button pull-center' onclick='deleteppvr(#=id#)'><img src='/Content/trashed.svg' width='40' height='40' /><br />Delete</a></div>").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Width(200);
11.                                                })
12.                                                    .Pageable()
13.                                                    .HtmlAttributes(new { style = " text-align:left; font-family:lato; font-zize:16px; " })
14.                                                    .DataSource(dataSource => dataSource
15.                                                    .Ajax()
16.                                                    .PageSize(100)
17.                                                    .Read(read => read.Action("GetPPVR", "PPV"))
18.                                                    .Model(model =>
19.                                                    {
20.                                                        model.Id(u => u.id);
21.                                                        model.Field(u => u.type).Editable(false);
22.                                                    })
23.                                                    .Update(update => update.Action("UpdatePPVR", "PPV"))
24.                                                    )
25. 
26..Editable(editable => editable.Mode(GridEditMode.InLine))
27. 
28.                                            )
29. 
30.

This brings the empty page. When I comment the line .Editable(editable => editable.Mode(GridEditMode.InLine)) page appears. It works well in MVC 5 but not in core 2.0.

Kindly suggest how can I achieve this.

Preslav
Telerik team
 answered on 24 May 2018
2 answers
829 views

Hi all,

 

I hope I can explain this.  I will try to put together a small sample, but I wanted to get this out there as soon as I could.

I'm using ASP.Net Core 2.0.

 

I have a grid that has a foreign key to an enum value on my model.  I have an EditorTemplate set up, which builds a SelectList from the enum values and binds it to a Kendo DropDownList, and it works great:

@model MyEnumType
 
@{
    var enumTypeSelect = Enum.GetValues(typeof(MyEnumType))
                                 .Cast<MyEnumType>()
                                 .Select(value => new SelectListItem()
                                 {
                                     Text = value.ToString(),
                                     Value = ((int)value).ToString()
                                 });
}
@(Html.Kendo().DropDownListFor(model => model)
                .DataTextField("Text")
                .DataValueField("Value")
                .BindTo(enumTypeSelect))

 

And in my grid:

@(Html.Kendo().Grid<MyViewModel>(Model.Items)
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(li => li.ID).Visible(false);
                    columns.Bound(li => li.EnumType).Width(170)
                                                .ClientTemplate("#: Description #")
                                                .EditorTemplateName("_GetValidEnumItemTypesPartial");
                ... rest of grid...

 

Now, though, I have a requirement where once I select certain enum types, I have to exclude OTHER enum types from subsequent entries in my model.  This is similar to, but not exactly, like a set of cascading drop downs, where the contents of the second depend upon the first.

So, I need to filter those enum types from the list.  I've tried a couple things: 

 

- setting the drop down's dataSource filter, like this:

$("#LineItemType").data().kendoDropDownList.dataSource.filter({ field: 'Value', operator: 'neq', value: 1 })

or

$("#LineItemType").data().kendoDropDownList.dataSource.filter({ field: 'Text', operator: 'neq', value: 'MyValue' })

I've tried this at various places: when I've added the item to the grid, and when I'm about to add the item.  This doesn't seem to work at all.

- Loading the list of valid values via Ajax - the problem there is that I don't know whether I'm updating the FIRST value (so I can set it to anything) or a NEW value (where I would restrict), so I can't reliably determine what the values should be.

Nothing seems to work so far.

 

There's an option that changes my data model - but I would rather not do this if I can avoid it.

Any help is appreciated - thanks!

 

Phil

 

 

 

 

 

Stefan
Telerik team
 answered on 24 May 2018
2 answers
192 views
I want to open window like dialog. freezing the background page. Can I get it.
Vincent
Top achievements
Rank 1
Iron
 answered on 24 May 2018
1 answer
172 views

Hi,

 

When I use  a simple MVC Core Kendo Grid and deploy it to Azure it works fine, however when I make the grid editable I get the following exception (only on Azure)

Failed method Kendo.Mvc.UI.GridBoundColumn`2.GetEditor

Exception System.InvalidOperationException: Cannot find compilation library location for package 'Microsoft.Win32.Registry' at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies) at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.<>c.<GetReferencePaths>b__8_0(CompilationLibrary library) at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext() at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable`1 parts, MetadataReferenceFeature feature) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences() at Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References() at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors() at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath) at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(String normalizedPath) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage) at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.TemplateRenderer.Render() at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.TemplateBuilder.Build() at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.GenerateEditor(ModelExplorer modelExplorer, String htmlFieldName, String templateName, Object additionalViewData) at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.Editor(String expression, String templateName, String htmlFieldName, Object additionalViewData) at Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperEditorExtensions.Editor(IHtmlHelper htmlHelper, String expression, String templateName, Object additionalViewData) at Kendo.Mvc.UI.GridBoundColumn`2.GetEditor(IHtmlHelper helper, HtmlEncoder encoder) at Kendo.Mvc.UI.Grid`1.<>c__DisplayClass66_1.<InitializeEditors>b__2(IGridBoundColumn column) at Kendo.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action) at Kendo.Mvc.UI.Grid`1.InitializeEditors() at Kendo.Mvc.UI.Grid`1.ProcessSettings() at Kendo.Mvc.UI.WidgetBase.RenderHtml(TextWriter writer) at Kendo.Mvc.UI.WidgetBase.ToHtmlString() at Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString() at Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.WriteTo(TextWriter writer, HtmlEncoder encoder) at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewBuffer.<WriteToAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderLayoutAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.<ExecuteAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.<ExecuteAsync>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext() --- End of stack trace from previous location where..........

 

Any help would be appreciated.

 

 

 

 

Konstantin Dikov
Telerik team
 answered on 23 May 2018
5 answers
240 views

I'm just starting to investigate ASP.NET Core 2.

I've just updated Visual Studio 2017 to get the latest version of Core, and installed UI for ASP.NET Core version 2017.3.1026.

However when I try to create a project using the Telerik ASP.NET Core MVC Application template, I'm unable to select a version of the framework for Core 2.1. The drop-down list is empty. The list shows version 2017.3.1026 for 1.1 and 1 projects.

Do I need another version to support 2.1? It is my understanding that the Q3 release supports Core 2?

I've attached a screenshot.

Shannon
Top achievements
Rank 1
 answered on 16 May 2018
1 answer
183 views
I have a fresh copy of VS 2017.  I downloaded the .NET Core UI package and attempted to run the examples to get a kick-start on development.  It apparently is looking for .NET 4.5.1 and .NET Core 1.0.  Are there any tricks to getting this working without installing the old libraries?    
Neli
Telerik team
 answered on 15 May 2018
1 answer
213 views

Is there a way of binding a Toolbar to data in the same way as the Treeview can be bound to data?

I have tried creating my toolbar list dynamically as follows.

List<ToolBarItem> toolbaritems = new List<ToolBarItem>();
ToolBarItem item = new ToolBarItem
{
    Text = "Button",
    Type = CommandType.Button
};
toolbaritems.Add(item);
ToolBarItemFactory factory = new ToolBarItemFactory(toolbaritems);
ViewData["DocumentToolbar"] = factory;

I have then tried to bind the data to the control as follows.

@(Html.Kendo().ToolBar()
    .Name("ToolBar")
    .Items((Action<ToolBarItemFactory>) ViewData["DocumentToolbar"]))

I am getting the following error.

InvalidCastException: Unable to cast object of type 'Kendo.Mvc.UI.Fluent.ToolBarItemFactory' to type 'System.Action`1[Kendo.Mvc.UI.Fluent.ToolBarItemFactory]'.

Is this possible? And if so, how?

Ianko
Telerik team
 answered on 15 May 2018
1 answer
261 views

I have a requirement to edit an object that has a list of texts associated with the object. The texts can not be edited again. I have found how to post a grid at this link https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/post-grid-with-form but the example uses incell editing.

So I decided to just change the incell to popup and extected it to work. At my surprise they were not. It seems popup requires the server editing. Is this true or are there posibilities to have the popup editing also on the client?

Tsvetina
Telerik team
 answered on 14 May 2018
1 answer
181 views

I want to use the telerik DropDownList to display a list of objects. I saw that the DropDownList support also an optional label but it seems it does not work.

Here is the code

@model IEnumerable<ActionViewModel>
 
@(Html.Kendo().DropDownList()
          .Name("actionDropDownList")
          .DataTextField("Display")
          .DataValueField("Id")
          .BindTo(Model)
          .OptionLabel(Localizer.GetString("Select an action..."))
          .Deferred()
 )

The generated script contains ""optionLabel":{"Name":"Select an action...","Value":"Select an action...","ResourceNotFound":true,"SearchedLocation":null}"

What do I have to give to the OptionalLabel so that it generates the optionalLabel with the properties of DataValueField and DataTextField?

 

 

Dan
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 14 May 2018
7 answers
1.2K+ views

Hi,

I have a strange issue using the HtmlHelper generating a Checkbox using @Html.Kendo().CheckBoxFor(m => m.enabled) and submitting the form to my controller.
The issue happens after submitting the form when some server validation errors occur.
The form is properly rendered again, but when i re-submit the form, i get an error when the model is deserialized. (The value 'on, false' is not valid for Enabled).
Looking at the serialized form data i can see enabled actually have the value "on,false" instead of just "false".
Any ideas ?
Thanks in advance.

Joana
Telerik team
 answered on 14 May 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?