I've followed code from the Grid Hierarchy demo to create a sub grid and have made it editable.
I have got validation and record editing working fine.
However I am struggling with creating new records. I have a constraint on the SQL table to disallow duplicate values (combination of 2 columns).
However I cannot seem to handle this error. Currently the UI adds the record, but doesn't create it in SQL.
I also noticed I cannot use decorate my controller action with HTTP post, as this yields a 404 error. Perhaps this is due to the sub grid.
Are there any examples there of a 2 level hierarchy grid with CRUD operations on the sub grid with error handling please?
EDIT: Does anyone know what this symbol means? I get this after trying to create a new record in the sub grid.
Hi,
I have created a new custom view to enforce values in a grid dropdown.
This works well, however it is not picking up data annotations defined in my model. Initially it didn't even trigger the validation messages, however I've managed to fix this by added "required = "required" in the HTMLATTRIBUTES. I can't seem to find a way to add data-val-required property here.
Is there a way to make this work? I have seen an example here on custom editors but this seems to complicated for what I need (enforcing static values in the grid dropdown).
Hopefully someone can kindly point me in the right direction.
@model string @(Html.Kendo().DropDownListFor(m => m) .Name("CountryCode") .Value(Model) .SelectedIndex(0) //.DataValueField("CountryCode") //.DataTextField("CountryCode") .BindTo(new string[] { "GB", "CN" }) .HtmlAttributes(new { style = "font-size: 12px;" , required = "required", data_bind = "value: CountryCode" }) )
EDIT:
This is the code for the grid, and how I can referencing this custom dropdown list:
<script id="AppRegGrid" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Myapp.Models.AppReg>()
.Name("AppReg_#=id#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(c => c.Number).Title("Registration Number").Width(120);
columns.Bound(c => c.CountryCode).Title("Country Code").Width(50).EditorTemplateName("AppRegistrationCountryCode");
columns.Bound(c => c.TypeCode).Title("Type Code").Width(50).EditorTemplateName("AppRegistrationTypeCode");
columns.Command(command => { command.Edit(); }).Width(200).HtmlAttributes(new { style = "text-align: center" }).HeaderHtmlAttributes(new { style = "text-align: center" });
})
.DataSource(dataSource => dataSource
.Ajax()
.Model (m => {
m.Id(l => l.AppRegNumID);
m.Field(l => l.AppRegNumID).Editable(false);
})
//.Sort(s => s.Add("ERPShipmentNumber").Ascending())
.PageSize(10)
.Read(read => read.Action("AppRegistrationNumbers_Read", "Admin", new { id = "#=id#" }))
.Update(update => update.Action("AppRegistrationNumbers_Update", "Admin"))
.Create(create => create.Action("AppRegistrationNumbers_Create", "Admin", new { id = "#=id#" }))
.ServerOperation(true)
)
.HtmlAttributes(new { style = "font-size: 12px;" })
.Height(200)
.ToolBar(tools => tools.Create())
.ToClientTemplate()
)
</script>
And this is by model:
public class AppReg { public int AppRegNumID { get; set; } [DisplayName("Registration Number")] [Required(ErrorMessage = "Please enter a valid registration number.")] public string Number { get; set; } [DisplayName("Country Code")] [StringLength(2)] [RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "2 letter ISO code only.")] [UIHint("AppRegistrationCountryCode")] [Required] public string CountryCode { get; set; } [Required] [DisplayName("Type Code")] [UIHint("AppRegistrationTypeCode")] public string TypeCode { get; set; } }
All the styling is broken, using bootstrap. I noticed a massive change in the files in Content/kendo/2023.1.314 (i.e. none of the previous files I had linked to actually exist anymore). I upgraded from 2023.1.117. Do I use bootstrap-4.css or bootstrap-main.css or what?
I ran the upgrade wizard and there was nothing about such massive changes.
Where's the documentation on these changes? Happy to read up but I couldn't find anything?
This is disgraceful for a minor upgrade to break/change everything so drastically.
Hi,
Is it possible to use filtering with List of child objects?
Example :
User
- Guid Id
- String Name
- List<PhoneNumber> PhoneNumbers
- Adress Adress
PhoneNumber
- Guid Id
- String PhoneNumber
Adress
- Guid Id
- String Street
If i filter on the street off a Adress and in the FilterDesriptor member is "Adres.Street" than it works correctly.
But how can you do it if it is a list? Like i want to filter on the PhoneNumbers?
I already tried "PhoneNumbers.PhoneNumber", but than i got the error :
System.ArgumentException: Invalid property or field - 'PhoneNumber' for type: ICollection`1
at Kendo.Mvc.Infrastructure.Implementation.Expressions.MemberAccessTokenExtensions.CreateMemberAccessExpression(IMemberAccessToken token, Expression instance)
Greetings,
Maxime
Kendo UI Grid Accessibility Issue
1.Kendo UI Grid is dividing Header and Content part into two different tables due to which when focus is on the data present in the table, screen readers are not linking them to the row/column headers.
2. While using tab key for navigating the Kendo grid,
2.1 focus is going again to the checkboxes after the last record in the kendo grid .
2.2 .when focus is on Column 10 , it is narrating the rest of the columns present in the Kendo grid. (Attached a pic for your reference)
Kendo Version: v2020.2.513
The following is traversal binding. The onDataBound method allows you to bind cells individually, similar to my following writing method of $("# spreadsheet"). data ("kendoPrepadsheet"). activeSheet(). range ("K3"). format ("yyyy MM dd");
My web application's implementation of the Upload widget does data validation through the component itself (max file size, allowed file types, etc.) as well as some extra validation through the Async.Save() handler's controller action (image validity, checking for animated images, etc.). It's my understanding that there are three potential results from the handler:
During the non-client side validation in my controller, should one of the checks fail we call "return Content(<string>)" and for the most part, this works as intended if the string contains any non-numeric characters. Initially I was simply returning a reference to a resource string defining the error and displaying it to the user in an alert describing what went wrong with the upload (via XMLHttpRequest.responseText); however, in the case of an undefined (by me) error this would result in an alert showing server response details that I don't wish to be displayed to the user. Thus I decided to send error codes and translate those client-side. This made it much easier to check for the error messages I mean to display to the user as well as have a default that displays for any unintended response. My problem is that if I return a string that is strictly numeric the handler doesn't result in an error.
Ex. return Content("Error: Bad File") would result in my error handler being called, and the text "Error: Bad File" being displayed in an alert.
But return Content("2") would result in a "successful" upload. The amount of numbers in the string doesn't matter, but if at any point a letter or symbol is included in the string it once again properly handles as an error.
I've already fixed my code to work by adding "error" into the string with the code number but I figured it was worth asking about since I would prefer to just use a numeric string. I'm puzzled as to what is causing the issue, as I don't believe strings containing only numbers are treated any differently than others unless they're being parsed. If I check the network response in the dev. console it shows the string as the response, which is what leads me to think it's something with the kendo widget.
Using .NET Framework 4.7.2, ASP.NET MVC 4 and Kendo.Mvc version 2021.2.616.545.
Hi,
I have used the tutorial https://demos.telerik.com/aspnet-mvc/grid/server-export in order to do a server export of a grid to excel. My grid has columns that contain text values, numerical values and date values.
I have set the formats accordingly on the .cshtml page, but it seems as though the exporter ignores this and it needs me to set the 'NumberFormat' to 'dd/mm/yyyy' in the SpreadCellFormat in order to show the date correctly. However that then applies the same format to every cell in the spreadsheet, meaning that the numerical columns turn to dates.
Has anyone else found this and have a solution?
Thanks
Becky
@(Html.Kendo().ScrollView()
.Name("svMessages")
//Afficher la pagination si plus d'un message.
.EnablePager(Model.NbMessages > 1)
.DataSource(d => d.Read(r => r.Action("AfficherMessagesAccueil", "Account"))))
[AllowAnonymous]
[HttpGet]
public ActionResult AfficherMessagesAccueil([DataSourceRequest] DataSourceRequest request)
{
var messages = new List<MessageAccueil>();
return Json(messages.ToDataSourceResult(request));
}
[AllowAnonymous]
[HttpPost]
public ActionResult AfficherMessagesAccueil([DataSourceRequest] DataSourceRequest request)
{
var messages = new List<MessageAccueil>();
return Json(messages.ToDataSourceResult(request));
}