Hello,
I am using an aspnetcore Grid and I noticed that the style of the edit form is different from the rest of the site.
For information, my site is setup to use the telerik bootstrap 4 style with custom colors (used the Telerik Theme Builder)
The problem I experience seems related to the classes used in my site versus the demo. In the demo (https://demos.telerik.com/aspnet-core/grid/editing-popup), the control classes all use a k- prefix. "k-textbox" "k-input" "k-numerictextbox". On my site, the classes are text-box single-line only. When I manually change them to k-textbox for example, the css applies and is displayed properly.
Did I configure something improperly for the classes used to be different from the demo?
Any help would be appreciated!
Hi Everyone,
I am trying to set the Kendo Grid with Group by specific column by default, so I have used the code snippet as shown below:
@(Html.Kendo().Grid<StudentRecord>().Name("Grid")
.Groupable()
.Sortable()
.GroupPaging(true)
.Group(x => x.Add(y => y.StartYear))
And I realised it always displays the StartYear groups in ascending order by default.
Please advise how I could set the StartYear groups to sort in descending order by default.
Thank you.
I am using the new System.Text.Json in asp.net core and I noticed that the grid does not bind to the model when using the new .net Core Json library. If I use Newtonsoft.Json the bind binding works fine.
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.AddKendo();
services.AddControllersWithViews();
//.AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
}
@(Html.Kendo().Grid<TestModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.email);
columns.Bound(e => e.username);
})
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Read(read => read.Action("Read", "home"))
)
)
Model
public class TestModel
{
public string archiveGuid { get; set; }
public string orgUid { get; set; }
public string orgName { get; set; }
public string orgExtRef { get; set; }
public string userUid { get; set; }
public string username { get; set; }
public string email { get; set; }
}
Here is what is returned with NewtonSoft JSON. I also noticed that D in the data response sent is capitalized when using Newtonsoft.json. Any ideas? It could be due to the contract resolver not being set when we are using the System.Text.Json as posted here https://www.telerik.com/forums/grid---binding-doesn't-work but I don't think there is a contract resolver option for the System.Text.Json.
So I have a grid, with a template for the command buttons. The reason I have the template, is I'm not allowing in-line editing, and the "edit" button will take the user to a detail page where they get access to the full model record.
I also have a "delete" button, but I can't figure out how to perform the delete from the template. I tried what I've seen in others and attempt to get the closest "tr" and then call "removerRow", but that did not work.
<script type="text/x-kendo-template" id="Commands"> <form method="post" action="@Url.Page("/clients/client", new { area = "" })" style="float: left; margin-right: .55rem"> <button type="submit" class="btn btn-info waves-effect waves-light">Edit</button> <input name="companyId" type="number" value="#= CompanyId #" hidden="hidden" /> @Html.AntiForgeryToken() </form> <button name="btnDelete" class="btn btn-danger waves-effect waves-light" onclick="deleteObject()">Delete</button> </script> <script> var commandTemplate = kendo.template($('#Commands').html()); </script> <script type="text/javascript"> function deleteObject() { var row = $(this).closest("tr"); $("#clientGrid").data("kendoGrid").removeRow(row); } </script>@(Html.Kendo().Grid<CaterX2.Models.Client.Client>() .Name("clientGrid") .Columns(columns => { columns.Bound(p => p.CompanyName).Title("Client"); columns.Bound(p => p.Address1); columns.Bound(p => p.Address2); columns.Bound(p => p.City); columns.Bound(p => p.State.StateCode).Title("State").Width(100); columns.Bound(p => p.ZipCode).Title("Zip Code").Width(150); columns.Bound(p => p.PhoneNumber).Title("Phone").Width(150); columns.Bound(p => p.CompanyId).ClientTemplate("#=commandTemplate(data)#").Width(200); }) .Pageable() .Sortable() .Scrollable() .Selectable(s => s.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row)) .HtmlAttributes(new { style = "height:430px;"}) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Events(events => events.Error("error_handler")) .Model(model => model.Id(p => p.CompanyId)) .Read(r => r.Url("/index?handler=Read").Data("forgeryToken")) .Update(e => e.Url("index?handler=Edit")) .Destroy(d => d.Url("index?handler=Delete").Data("forgeryToken")) ) )
I'm trying to define a grid where the first column is a checkbox and the 2nd has a large font bound to "name" with a small font below it showing the "description". I'd appreciate a working example.
This is NOT working:
<script id="rowTemplate" type="text/x-kendo-tmpl"> <tr data-uid="#: uid #"> <td class="checkbox"> <input type="checkbox" name="optCheck" /> </td> <td class="details"> <span class="name">#: Name #</span> <span class="desc">#: Description #</span> </td> </tr> </script> @(Html.Kendo().Grid<SessionOptionTemplate>() .Name("template-grid") .ClientRowTemplate("rowTemplate") .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Read(read => read.Action("IndexJson", "SessionOptionTemplates") .Data("getData")) ))
Style
<style> .checkbox { width: 75px; } .details { width: 400px; } .name { display: block; font-size: 1.6em; } .desc { display: block; padding-top: 1.6em; font-size: small }</style>
I'm failing somewhere in my load of a TreeList. I added a simple error handler like this:
<script id="icon-template" type="text/x-kendo-template"> <div class='group-photo' style='background-image: url(@Url.Content("~/images/32/neighbourhood.png"));'></div> <div class='group-name'>#: Name #</div></script><div class="demo-section k-content"> <h4>Customer Groups</h4> @(Html.Kendo().TreeList<GsiPortal.Models.Group>() .Name("treelist") .Columns(columns => { columns.Add().Field(e => e.Name).Width(220).TemplateId("icon-template"); columns.Add().Field(e => e.Description); columns.Add().Field(e => e.AddTimestamp).Width(220).Title("Timestamp").Format("{0:MMMM d, yyyy}"); columns.Add().Command(c => { c.CreateChild().Text("Add"); }).HtmlAttributes(new {style = "text-align: center;"}); columns.Add().Command(c => { c.Edit(); }).HtmlAttributes(new { style = "text-align: center;" }); columns.Add().Command(c => { c.Destroy(); }).HtmlAttributes(new { style = "text-align: center;" }); }) .Editable(e => e.Mode(TreeListEditMode.PopUp).TemplateName("GroupEdit")) .Selectable(selectable => selectable.Mode(TreeListSelectionMode.Single)) .DataSource(dataSource => dataSource .ServerOperation(false) .Create(create => create.Action("CreateJson", "Groups")) .Read(read => read.Action("AllJson", "Groups") .Data("groupsRead")) .Update(update => update.Action("UpdateJson", "Groups")) .Destroy(delete => delete.Action("DestroyJson", "Groups")) .Model(m => { m.Id(f => f.Id); m.ParentId(f => f.ParentId); m.Expanded(true); m.Field(f => f.Name); m.Field(f => f.Description); m.Field(f => f.AddTimestamp).Editable(false); }) .Events(x => x.Error("onError")) )) <script> var groupId = Number(@(ViewBag.GroupId)); function groupsRead() { return { id: groupId }; } function onError(e) { alert(e.toString()); } </script>
However, this doesn't give me any clue as to what object type is there to pull the message from. What is the recommended way of doing Error Handling with this control that will give me some actionable information?
Thanks, Joel

I've implemented PDF export functionality with a Grid. I'm trying to set the column width (auto) for one of columns of the report that gets generated because the some values in the column of the report are being truncated, or not seen in the PDF. I've tried
/* doesn't work */
.k-pdf-export colgroup > col {
width: auto !important;
}
/* doesn't work */
.k-pdf-export colgroup > col:nth-child(2) {
word-wrap: break-word;
}
/* makes the column as large as the report, completely useless */
.k-pdf-export colgroup > col:nth-child(2) {
width: 100% !important;
}
/* this works! But I don't want to hard code in a value */
.k-pdf-export colgroup > col:nth-child(2) {
width: 200px !important;
}

Attached is the same grid header displays on Chrome and Edge browser.
Is there a way to force the header not to display C... in Chrome?
var RHCenterOverFlow = "text-align:center; font-size:10px; font-weight:bold; padding:0.5px; overflow:visible; white-space:normal";
columns
.Bound(c => c.Class)
.Title("Class")
.HeaderHtmlAttributes(new { style = RHCenterOverFlow })
.Width(40)
.MinResizableWidth(40);
Thanks.
I am populating a grid with dynamic data. I would like to center all but the left column horizontally. The left column should be left-aligned. I've looked at some examples and have not been able to get it to work. My code follows the pattern below. Where/how can I center align all columns that are not the one with the name "LeftMostColumn?" I've mocked up a couple of places where I think this might happen. Please advise. Thanks!
@(Html.Kendo().Grid<dynamic>() .Name("Grid") .Columns(columns => { foreach (System.Data.DataColumn column in Model.MyDataData.Columns) { var c = columns.Bound(column.ColumnName); if (column.ColumnName != "LeftMostColumn") { // center the contents of the column } } }) .DataSource(dataSource => dataSource .Ajax() .Model(model => { foreach (System.Data.DataColumn column in Model.MyDataData.Columns) { var field = model.Field(column.ColumnName, column.DataType); if (column.ColumnName != "LeftMostColumn") { // center the contents of the field? } } }).Read(read => read.Url(Url.Page("./MyData", new { handler = "GetData_Read" })).Data("forgeryToken")) ))