Hello All, i need an help to resolve the following error. This error occurs after I have added this line of code(columns.Bound(p => p.Id).Title("ID").Hidden(true)) to the grid .
Error I am receiving:
<[Error] An unhandled exception has occurred: One or more compilation failures occurred:
List.cshtml(38,30): error CS1061: 'ListItemViewModel' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'ListItemViewModel' could be found (are you missing a using directive or an assembly reference?)
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:
List.cshtml(38,30): error CS1061: 'ListItemViewModel' does not contain a definition for 'd' and no extension method 'Id' accepting a first argument of type 'DecisionListItemViewModel' could be found (are you missing a using directive or an assembly reference?)
at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(RazorCodeDocument codeDocument, String generatedCode)
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.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.LocatePageFromPath(String executingFilePath, String pagePath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at CPAS.Web.Startup.<>c.<<Configure>b__8_3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at CPAS.Web.Startup.<>c__DisplayClass8_0.<<Configure>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()>
My code:
<use the editor's "Insert code sample" functionality to insert a minimal amount of code which reproduces the problem>
--- End of stack trace from previous location where exception was thrown ---
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.LocatePageFromPath(String executingFilePath, String pagePath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at CPAS.Web.Startup.<>c.<<Configure>b__8_3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at CPAS.Web.Startup.<>c__DisplayClass8_0.<<Configure>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
My code:
@(Html.Kendo().Grid<ListItemViewModel>().Name("grid").Columns(columns =>{ columns.Bound(p => p.Name);
columns.Bound(p => p.Id).Title("ID").Hidden(true);}).Pageable(pageable => pageable
.Refresh(true).PageSizes(new int[] { 10, 20, 50, 100 })).Groupable(false).Scrollable().ColumnMenu().Selectable(s => s.Mode(GridSelectionMode.Single)).Sortable(s => s.SortMode(GridSortMode.MultipleColumn)).Filterable(filterable => filterable.Mode(GridFilterMode.Menu)).ClientDetailTemplateId("template").Events(events => events.Change("onChange")).HtmlAttributes(new { style = "margin-top:10px;height:400px;margin-bottom:35px;" }).DataSource(dataSource => dataSource
.Ajax().PageSize(20).Events(events => events.Error("error_handler")).Model(model =>{ model.Id(p => p.Id);}).Read(read => read.Action("Get", "Lists").Data("getFilters"))).Deferred())
I want to show a Kendo window, type something in a textbox in the window, and return the value from to the parent page. How can I do this?
My window definition.
<
kendo-window
name
=
"InstallerSearch"
title
=
"Search for Installer"
draggable
=
"true"
resizable
=
"true"
width
=
"1100"
height
=
"550"
modal
=
"true"
visible
=
"false"
on-close
=
"onClose"
actions
=
"actions"
iframe
=
"true"
>
<
content
>
loading...
</
content
>
<
popup-animation
enabled
=
"true"
/>
</
kendo-window
>
JavaScript to open window
function
selectInstaller() {
var
window = $(
"#InstallerSearch"
).data(
"kendoWindow"
);
window.refresh({
url:
"@Url.Content("
/Admin/Installers/Search/
")"
});
window.open();
window.center();
}
Razor page content for the window
Installer Name<
br
/>
<
input
name
=
"InstallerName"
id
=
"InstallerName"
type
=
"text"
class
=
"form-control-md"
/>
JavaScript for the close where I want to get the value in the textbox in the window but user input is undefined.
function
onClose() {
var
userinput = $(
"#InstallerName"
).val();
alert(userinput);
}
Hello,
I am using a Kendo Toobar in RTL mode, and I have a couple of SplitButtons on it. I have two questions:
1- Since the Toolbar is set to display its contents in Right-to-Left (RTL) mode, the drop-down arrows for the SplitButtons are displaying on the left side (which is understandable). However, I would like these arrows to display on the right side of the SplitButtons. How can I achieve this?
2- There is a line separating the drop-down arrow and its text (please see image). How do I remove this line so that it's one smooth box?
Thanks,
Shawn A.
Hi All,
I created a simple project using the Telerik grid template. In my script, I update "Freight" to zero for the selected row. However, I want to set ALL ROWS that match the CustomerID of the selected row to zero.
Here are the peices:
VIEW
@{
ViewData["Title"] = "Home Page";
}
<
div
class
=
"row"
>
<
div
class
=
"col-xs-18 col-md-12"
>
@(Html.Kendo().Grid<
TelerikAspNetCoreApp3.Models.OrderViewModel
>()
.Name("grid")
.Selectable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(events =>
{
events.Change("onSelectedRow");
})
.Columns(columns =>
{
columns.Bound(p => p.CustomerID)
.ClientGroupHeaderColumnTemplate("CustomerID");
columns.Bound(p => p.OrderID);
columns.Bound(p => p.Freight);
})
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
.Group(groups =>
{
groups.Add(g => g.CustomerID);
})
.Model(model =>
{
model.Field(p => p.OrderID).Editable(false);
model.Field(p => p.CustomerID).Editable(false);
})
)
)
)
</
div
>
</
div
>
<
script
>
function onSelectedRow(e) {
var gview = $("#grid").data("kendoGrid");
var selectedItem = gview.dataItem(gview.select());
var custId = selectedItem.CustomerID;
//I want to update ALL freight fields to 0 where CustomerID equals custId, not just the selectedItem
selectedItem.set("Freight", 0); //Fix or update this to update all rows
}
</
script
>
MODEL
namespace TelerikAspNetCoreApp3.Models
{
public class OrderViewModel
{
public int OrderID {get;set;}
public double CustomerID{get;set;}
public decimal? Freight{get;set;}
}
}
CONTROLLER
namespace TelerikAspNetCoreApp3.Controllers
{
public class GridController : Controller
{
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
{
var result = Enumerable.Range(0, 50).Select(i => new OrderViewModel
{
CustomerID = (i+100)/10,
OrderID = i,
Freight = i * 10
});
var dsResult = result.ToDataSourceResult(request);
return Json(dsResult);
}
}
}
If this is completely the wrong approach, I'll take ideas for a better/easier solution.
Thank you in advance!
I want to display a line on the value axis of my bar chart. When using JS it can be done like this:
valueAxis: {
notes: {
line: {
length: 340,
width: 3,
color:
"#ff0000"
},
data: [{value: 730, label: {text:
"mid"
}}]
}
},
But when using a TagHelper I am missing the "data: [...]" part. How can I tell the notes-taghelper where to draw the line?
<value-axis>
<value-axis-item>
<notes>
<chart-value-axis-notes-line length=
"340"
width=
"3"
/>
</notes>
</value-axis-item>
</value-axis>
Hello,
Is posible to override behavior when multiple option is set, to not holding CTRL button to select multiple dates. I want user to use this behavior as default just by normal mouse click on dates.
Thanks.
I noticed that my ModelState becomes invalid if the user doesn't select any value from a cascaded set of dropdowns. Once you select a value, it becomes valid. How do I fix this, and actually save my model if the user doesn't actually select anything? Not selecting anything just means I won't save anything on Post.
thanks
For a bar chart there is a property Stack
HtmlHelper-Example:
.SeriesDefaults(sd => sd.Bar().Stack(
true
))
This I can not find in the TagHelper. How can I display a bar chart with stacked bars?
Hello,
I have problem with the ImageBrowser component inside the Editor component in .NET Core 2.2. (It's working in the local example, but I not find the difference)
I use the local example as starting point, I copy the code from the example to my project.
1. My controller:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Kendo.Mvc.UI;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyCoreSite.Models.Image;
using MyCoreSite.Mvc.Attributes;
namespace MyCoreSite.Areas.Admin.Controllers
{
[ViewLayout("_LayoutAdmin")]
public class ImageBrowserController : EditorImageBrowserController
{
private const string contentFolderRoot = "shared/";
private const string folderName = "Images/";
private static readonly string[] foldersToCopy = new[] { "shared/images/employees" };
/// <
summary
>
/// Gets the base paths from which content will be served.
/// </
summary
>
public override string ContentPath
{
get
{
return CreateUserFolder();
}
}
public ImageBrowserController(IHostingEnvironment hostingEnvironment)
: base(hostingEnvironment)
{
}
public override JsonResult Read(string path)
{
var z = base.Read(path);
return z;
}
private string CreateUserFolder()
{
var virtualPath = Path.Combine(contentFolderRoot, "UserFiles", folderName);
var path = HostingEnvironment.WebRootFileProvider.GetFileInfo(virtualPath).PhysicalPath;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
foreach (var sourceFolder in foldersToCopy)
{
CopyFolder(HostingEnvironment.WebRootFileProvider.GetFileInfo(sourceFolder).PhysicalPath, path);
}
}
return virtualPath;
}
private void CopyFolder(string source, string destination)
{
if (!Directory.Exists(destination))
{
Directory.CreateDirectory(destination);
}
foreach (var file in Directory.EnumerateFiles(source))
{
var dest = Path.Combine(destination, Path.GetFileName(file));
System.IO.File.Copy(file, dest);
}
foreach (var folder in Directory.EnumerateDirectories(source))
{
var dest = Path.Combine(destination, Path.GetFileName(folder));
CopyFolder(folder, dest);
}
}
}
}
2. My view:
@* Make sure tag helpers are not available for the Editor content *@
@removeTagHelper "*, Microsoft.AspNet.Mvc.Razor"
@removeTagHelper "*, Microsoft.AspNetCore.Mvc.Razor"
@{
ViewBag.Title = "Template";
PageInfo PI = ViewBag.PI;
}
<
div
class
=
"content-heading"
>
<
div
>
Page title
<
small
>Subtitle</
small
>
</
div
>
</
div
>
<
div
class
=
"row"
>
<
div
class
=
"col-xl-12"
>
<
url
class
=
"nav-link text-dark"
asp-area
=
"Admin"
asp-controller
=
"ImageBrowser"
asp-action
=
"Index"
><
localize
>Image Browser</
localize
></
url
>
</
div
>
<
div
class
=
"col-xl-12"
>
@(Html.Kendo().Editor()
.Name("editor")
.HtmlAttributes(new { style = "width: 100%;height:440px" })
.Tools(tools => tools
.Clear()
.Bold().Italic().Underline().Strikethrough()
.JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
.InsertUnorderedList().InsertOrderedList()
.Outdent().Indent()
.CreateLink().Unlink()
.InsertImage()
.InsertFile()
.SubScript()
.SuperScript()
.TableEditing()
.ViewHtml()
.Formatting()
.CleanFormatting()
.FontName()
.FontSize()
.ForeColor().BackColor()
.Print()
)
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/shared/UserFiles/Images/{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Destroy("Destroy", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
)
.Value(@<
text
>
<
p
>
Example
</
p
>
</
text
>)
)
</
div
>
</
div
>
@section Styles {
}
@section Scripts {
}
3. The result:
[Attached file: teler1.jpg]: It's shows undefined items. The image file structure can be find at the right. The item and file count are equal.
[Attached file: teler2.jpg]: It seems that the control detect the files as a directory instead of file.
4. Reference scripts used:
<
script
src
=
"/js/telerik/jszip.min.js"
></
script
>
<
script
src
=
"/js/telerik/kendo.all.min.js"
></
script
>
<
script
src
=
"/js/telerik/kendo.aspnetmvc.min.js"
></
script
>
<
script
src
=
"/js/telerik/cultures/kendo.culture.en-US.min.js"
></
script
>
<
script
src
=
"/js/telerik/messages/kendo.messages.en-US.min.js"
></
script
>
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
kendo.culture("en-US");
});
</
script
>
Can you help me please solve this problem?
Thank you!
I have requirement to allow editable row for one column in Parent row of Parent-Child Grid. I am able to display field in popup window by hiding all other non required field. But I am getting validation message for hide field while update the required field. Please help me to find out the solution either displays only required field in popup window without hiding all other fields or how to stop validation for non-required field in popup window. Below is my code in View:
@model IEnumerable<StarTrax.Mvc.Models.ToFindListViewModel>
@{
ViewData["Title"] = "View";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Name).Width(110).Title("List Name");
columns.Bound(e => e.CreatedAt).Width(110).Title("Create Date").Format("{0:MM/dd/yyyy}");
columns.Bound("").Width(110).Title("Created By");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp)).HtmlAttributes(new { style = "width:300px;font-size:12px;height: 200px;" })
.Sortable()
.Pageable()
.Scrollable()
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.EntityId);
})
.Read(read => read.Action("GetAll", "ToFindList"))
.Update(update => update.Action("Edit", "ToFindList"))
.Destroy(update => update.Action("Delete", "ToFindList"))
)
.Events(events =>
{
events.DataBound("dataBound");
events.Edit("hideField");
})
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid< StarTrax.Mvc.Models.AssetToFindViewModel> ()
.Name("grid_#=EntityId#")
.Columns(columns =>
{
columns.Bound(o => o.Asset.EPC.BarCode).Width(110).Title("Barcode");
columns.Bound(o => o.Asset.SerialNumber).Width(110).Title("Serial Number");
columns.Bound(o => o.Asset.Name).Width(200).Title("Asset Name");
columns.Bound(o => o.Asset.Status).Width(200);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("GetToFindAssets", "ToFindList", new { toFindListId = "#=EntityId#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
function hideField(e) {
$("#CreatedAt").hide();
$("#CreatedAt").editable = false;
$("label[for='CreatedAt']").hide();
$("#OrganizationId").hide();
$("#OrganizationId").editable = false;
$("label[for='OrganizationId']").hide();
$("#CreatedBy").hide();
$("#CreatedBy").editable = false;
$("label[for='CreatedBy']").hide();
$("#LastModifiedBy").hide();
$("#LastModifiedBy").editable = false;
$("label[for='LastModifiedBy']").hide();
$("#UpdatedAt").hide();
$("#UpdatedAt").editable = false;
$("label[for='UpdatedAt']").hide();
$("#EntityId").hide();
$("#EntityId").editable = false;
$("label[for='EntityId']").hide();
$("#Deleted").hide();
$("#Deleted").editable = false;
$("label[for='Deleted']").hide();
}
</script>
<script type="text/javascript">
function error_handler(e) {
debugger;
if (e.errors) {
var message = "Error:\n";
var grid = $('#locationGrid').data('kendoGrid');
var gridElement = grid.editable.element;
var validationMessageTemplate = kendo.template(
"<div id='#=field#_validationMessage' class='k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error' " +
"style='margin: 0.5em;' data-for='#=field#' data-val-msg-for='#=field#' role='alert'>" +
"<span class='k-icon k-warning'> " +
"</span > " +
"#=message#" +
"<div class='k-callout k-callout-n'> " +
"</div > " +
"</div>"
);
$.each(e.errors, function (key, value) {
if (value.errors) {
gridElement.find("[data-valmsg-for=" + key + "],[data-val-msg-for=" + key + "]").replaceWith(validationMessageTemplate({ field: key, message: value.errors[0] }));
gridElement.find("input[name=" + key + "]").focus();
//alert(value.errors[0]);
}
});
grid.one("dataBinding", function (e) {
e.preventDefault();
});
}
}
</script>