Declined
Last Updated: 04 Feb 2021 12:05 by ADMIN

When you create a Grid using a TModel that inherits from DynamicObject, a type cast exception is thrown when setting the DataSource Model Id property.

public class Metadata : DynamicObject

{ ... }  


...
.DataSource(dataSource =>
{
    dataSource.Ajax()
      .Model(model =>
      {
          model.Id("Id");
      });
})

A type cast exception is thrown by the following line in Kendo\AspNet.Core\Kendo.Mvc\UI\DataSource\Fluent\DataSourceModelDescriptorFactoryBase.cs because ModelDynamicDataKey is not generic, so it cannot be cast to IDataKey<TModel>

dataKey = (IDataKey<TModel>)new ModelDynamicDataKey(fieldName, lambdaExpression);


The following code changes fix the issue:

DataSourceModelDescriptorFactoryBase.cs

namespace Kendo.Mvc.UI.Fluent
{
	using System.Reflection;
	using Extensions;

	/// <summary>
	/// Defines the fluent interface for configuring the <see cref="DataSource"/> Model definition.
	/// </summary>
	/// <typeparam name="TModel">Type of the model</typeparam>
	public abstract class DataSourceModelDescriptorFactoryBase<TModel> : IHideObjectMembers
        where TModel : class
    {
        protected readonly ModelDescriptor model;

        public DataSourceModelDescriptorFactoryBase(ModelDescriptor model)
        {
            this.model = model;
        }

        /// <summary>
        /// Specify the member used to identify an unique Model instance.
        /// </summary>
        /// <param name="fieldName">The member name.</param>
        protected void Id(string fieldName)
        {
            IDataKey<TModel> dataKey;
            if (typeof(TModel).IsDynamicObject())
            {
                var lambdaExpression = ExpressionBuilder.Expression<TModel, object>(fieldName);
                dataKey = new ModelDynamicDataKey<TModel>(fieldName, lambdaExpression);
            }
            else
            {
                dataKey = GetDataKeyForField(fieldName);
            }

            dataKey.RouteKey = dataKey.Name;

            model.Id = dataKey;
        }

        protected IDataKey<TModel> GetDataKeyForField(string fieldName)
        {
            var lambdaExpression = ExpressionBuilder.Lambda<TModel>(fieldName);
            var fieldType = typeof(ModelDataKey<,>).MakeGenericType(new[] { typeof(TModel), lambdaExpression.Body.Type });

            var constructor = fieldType.GetConstructor(new[] { lambdaExpression.GetType() });

            return (IDataKey<TModel>)constructor.Invoke(new object[] { lambdaExpression });
        }
    }
}

 

ModelDynamicDataKey.cs

namespace Kendo.Mvc.UI
{
    using System;
    using System.Linq.Expressions;
    using Microsoft.AspNetCore.Mvc.Rendering;

    internal class ModelDynamicDataKey<TModel> : IDataKey<TModel>
        where TModel : class
    {
        public ModelDynamicDataKey(string memberName, Expression<Func<TModel, object>> expression)
        {
            RouteKey = "id";
            Name = memberName;
            Expression = expression;
            Value = expression.Compile();
        }

        public string Name
        {
            get;
        }

        public string RouteKey
        {
            get;
            set;
        }

        public Func<TModel, object> Value
        {
            get;
        }

        public Expression<Func<TModel, object>> Expression
        {
            get;
        }

        public object GetValue(object dataItem)
        {
            try
            {
                return Value((TModel)dataItem);
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException)
            {
                return null;
            }
        }

        public string HiddenFieldHtml(IHtmlHelper<TModel> htmlHelper)
        {
            return htmlHelper.Hidden(Name, null, new { id = "" }).ToString();
        }
    }
}


Declined
Last Updated: 05 Dec 2019 07:58 by ADMIN

When Batch update mode is set to true, Popup editing mode should write back the data to grid and not call the update actions directly upon confirming the popup editing window.

I have a page containing a grid, in the toolbar there are following buttons:

* Add

* Edit

* Delete 

When the user clicks Edit, the selected row is edited using the pop-up window. Alternatively the user can also double click the row to start editing. 

On the bottom of the page there is a Save and Cancel Changes button. The save changes must update all applied changes, the cancel button must undo them.

At current when Popup editing is used and the user confirms the popup window, changes are immediately written to the database. This breaks functionality of the Cancel button. Cancel will now only apply to deletes.

I need popup functionality because I have too many columns to use in-cell editing.

Telerik is ignoring the setting batch(true) when doing popup editing, so this could even be considered a bug instead of a feature request!

 

 

Declined
Last Updated: 15 Jul 2021 07:20 by ADMIN
Created by: Ravi
Comments: 2
Category: Grid
Type: Feature Request
1

Hi Team,

I'd like to request adding a configuration to the Kendo UI Grid or ExcelExport event which would be a setting to autofit the Excel sheet columns instead of changing the workbook.sheets.columns.autowidth. 

Thank you!

Declined
Last Updated: 04 Sep 2024 10:31 by ADMIN

### Bug report

When the Grid is grouped by a specified column, and this column has a "groupFooterTemplate" that contains aggregates from other fields, it cannot be exported to Excel. It throws a JavaScript exception.

### Reproduction of the problem

1) Group the Grid by the column "ProductName".

2) Export it to Excel through the built-in command "Export to Excel".

3) JS exception is thrown.

A Dojo sample for reproduction: https://dojo.telerik.com/UyUruyOZ

### Expected/desired behavior

The Excel export should work as expected when the Grid is grouped.

### Environment

* **Kendo UI version: 2022.2.802
* **jQuery version: 1.12.4
* **Browser: [all]

Declined
Last Updated: 10 Feb 2021 08:42 by ADMIN

Hi!

We're using a drop down list as a grid cell's edit template, but.. our users are unable to properly edit the rows at the bottom of the grid due to drop down list going off the page, and closing when they attempt to scroll.

 

any ideas?

Declined
Last Updated: 31 Mar 2020 14:56 by ADMIN
Created by: Dan
Comments: 3
Category: Grid
Type: Feature Request
0

Kendo UI has the property https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/scrollable that can not be set in the UI for ASP.NET Core with the value TRUE

The reason I am asking is because if I change it on document ready using the grid.setOptions if the grid has autobind then the Read method is executed twice.

Declined
Last Updated: 12 Aug 2021 07:46 by ADMIN
Created by: Carl
Comments: 3
Category: Grid
Type: Feature Request
0
An officially supported Telerik editor control for datatype XML as a grid column  ---  so that we can easily and conveniently edit XML data in a grid column
Declined
Last Updated: 04 May 2023 13:30 by ADMIN
Created by: Michael
Comments: 1
Category: Grid
Type: Bug Report
0

If I put the Grid into a kendo-template for the TileLayout control, the ClientTemplate does not work properly. It only gets called once regardless of the number of items in the grid and the data is not being passed in. 

This is my column definition:

columns.Bound(c => c.DocumentKey).Title(" ").ClientTemplate("#=CommandTemplate(data)#").Width(70);

And I am calling the .ToClientTemplate() on the Grid. Everything else work great except for this one issue.

I have not been able to find any other info, so what am I missing?

Declined
Last Updated: 01 Sep 2023 13:31 by ADMIN
Created by: Stacy
Comments: 1
Category: Grid
Type: Bug Report
0

 

I am using the Grid with two editor template bound to viewdata to populate the components.

Now this is code that I wrote in 2017 that I recent upgraded to .NET 7 ASP Core and has work all those years with no issue. So I think this may be a regression in the grid code.

I have embedded the relevant code leaving out the grid views custom javascript since it isn't relevant.

The behavior that I am seen is that the the grids model properties that do NOT use a customer editor template are not being bound when the save event fires.

public class AlertRuleGridViewModel
{
    public int Id { get; set; }

    [UIHint("ComponentEditor")]
    public string? Component { get; set; }

    [UIHint("EmailAddress")]
    public string? Email { get; set; }

    [UIHint("TypeEditor")]
    public string? Type { get; set; }

    [UIHint("Boolean")]
    public bool Enabled { get; set; }
}



<div class="container alert-rules-grid">
    @(Html.Kendo().Grid<AlertRuleGridViewModel>()
        .Name("alert-grid")
        .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(l => l.Id);
            model.Field(field => field.Id).Editable(false);
            model.Field(field => field.Type).DefaultValue(ViewData["defaultType"] as String);
        })
        .PageSize(12)
        .Sort(a => a.Add("Id").Descending())
        .Read(read => read.Action("GetRules", "Alerts").Data("additionalData"))
        .Create(update => update.Action("UpdateRule", "Alerts"))
        .Update(update => update.Action("UpdateRule", "Alerts"))
        .Destroy(destroy => destroy.Action("DeleteRule", "Alerts"))
        .Events(e => e.Error("gridErrorHandler"))
        )
        .Columns(columns =>
        {
            columns.Bound(b => b.Id).Title("Id").Visible(true).Width("4%");
            columns.Bound(b => b.Component).Title("Component").EditorTemplateName("ComponentEditor").Visible(true);
            columns.Bound(b => b.Email).Title("Email").Visible(true);
            columns.Bound(b => b.Type).Title("Log Type").EditorTemplateName("TypeEditor").Visible(true);
            columns.Bound(b => b.Enabled).Title("Enabled").ClientTemplate("#=renderStatus(data)#").Visible(true);
            columns.Command(command =>
            {
                command.Edit();
                command.Destroy();
            });
        }
        )
        .ToolBar(toolBar =>
        {
            toolBar.ClientTemplateId("toolBarTemplate");
        })
        .Events(events =>
        {
            events.Cancel("onCancelEdit");
            events.Save("onSave");
        }
        )
        .Editable(editable => editable.Mode(GridEditMode.InLine))
        .Pageable() // Enable paging
        .Sortable() // Enable sorting
        .Scrollable(s => s.Height("auto"))
        .Resizable(resize => resize.Columns(true))
        )
</div>

I suspect the issue is the generated html for the input that used the editor template.

The data-bind attribute is set to "value:Component.Component" which should be "value:Component"
<td class="k-table-td" role="gridcell" data-container-for="Component">
	<span class="k-input k-combobox k-combobox-clearable k-input-solid k-input-md k-rounded-md k-valid" style="">
		<input name="Component.Component_input" class="k-input-inner k-valid" type="text" autocomplete="off" title="" role="combobox" aria-expanded="false" style="" tabindex="0" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-autocomplete="none" aria-controls="Component_Component_listbox" data-bind="value:Component.Component_input">
			<span unselectable="on" class="k-clear-value k-hidden" title="clear" role="button" tabindex="-1">
				<span class="k-svg-icon k-svg-i-x" aria-hidden="true">
					<svg viewBox="0 0 512 512" focusable="false" xmlns="http://www.w3.org/2000/svg">
						<path d="M416 141.3 301.3 256 416 370.7 370.7 416 256 301.3 141.3 416 96 370.7 210.7 256 96 141.3 141.3 96 256 210.7 370.7 96l45.3 45.3z"/>
					</svg>
				</span>
			</span>
			<button type="button" class="k-input-button k-button k-button-md k-button-solid k-button-solid-base k-icon-button" aria-label="expand combobox" role="button" tabindex="-1">
				<span class="k-svg-icon k-svg-i-caret-alt-down k-button-icon" aria-hidden="true">
					<svg viewBox="0 0 512 512" focusable="false" xmlns="http://www.w3.org/2000/svg">
						<path d="M256 352 128 160h256L256 352z"/>
					</svg>
				</span>
			</button>
			<input id="Component_Component" name="Component.Component" type="text" value="" data-role="combobox" aria-disabled="false" aria-readonly="false" style="display: none;" data-bind="value:Component.Component"/>
			<script>kendo.syncReady(function(){jQuery("#Component_Component").kendoComboBox({"dataTextField":"Name","dataValueField":"Value","valuePrimitive":true,"dataSource":[{"Name":"AppLog.Common.Test","Value":"AppLog.Common.Test"},{"Name":"AppLog.WebAPI","Value":"AppLog.WebAPI"},{"Name":"BadgeReader","Value":"BadgeReader"},{"Name":"CCS.WebUI","Value":"CCS.WebUI"},{"Name":"LVCVA.AppLog.Internal.Web","Value":"LVCVA.AppLog.Internal.Web"},{"Name":"LVCVA.AppSecurity.Domain","Value":"LVCVA.AppSecurity.Domain"},{"Name":"Registration.WPF.UI","Value":"Registration.WPF.UI"},{"Name":"spLogApplicationMessage","Value":"spLogApplicationMessage"}]});});</script>
			<span class="field-validation-valid" data-valmsg-for="Component" data-valmsg-replace="true"/>
		</td>
The data-bind attribute is set to "value:Type.Type" which should be "value:Type"
<td class="k-table-td" role="gridcell" data-container-for="Type">
	<span title="" class="k-picker k-dropdownlist k-picker-solid k-picker-md k-rounded-md k-valid" unselectable="on" role="combobox" aria-expanded="false" tabindex="0" aria-controls="Type_Type_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-describedby="e73b8727-5e28-4d9b-9faa-df8239f54aa5" style="">
		<span id="e73b8727-5e28-4d9b-9faa-df8239f54aa5" unselectable="on" class="k-input-inner">
			<span class="k-input-value-text"/>
		</span>
		<span role="button" class="k-input-button k-button k-button-md k-button-solid k-button-solid-base k-icon-button" aria-label="select" type="button">
			<span class="k-svg-icon k-svg-i-caret-alt-down k-button-icon" aria-hidden="true">
				<svg viewBox="0 0 512 512" focusable="false" xmlns="http://www.w3.org/2000/svg">
					<path d="M256 352 128 160h256L256 352z"/>
				</svg>
			</span>
		</span>
		<input id="Type_Type" name="Type.Type" type="text" value="" data-role="dropdownlist" style="display: none;" data-bind="value:Type.Type"/>
		<script>kendo.syncReady(function(){jQuery("#Type_Type").kendoDropDownList({"dataTextField":"Type","dataValueField":"Value","valuePrimitive":true,"dataSource":[{"Type":"Critical","Value":"Critical"},{"Type":"Error","Value":"Error"},{"Type":"Warning","Value":"Warning"},{"Type":"Information","Value":"Information"},{"Type":"Verbose","Value":"Verbose"},{"Type":"Start","Value":"Start"},{"Type":"Stop","Value":"Stop"},{"Type":"Suspend","Value":"Suspend"},{"Type":"Resume","Value":"Resume"}]});});</script>
		<span class="field-validation-valid" data-valmsg-for="Type" data-valmsg-replace="true"/>
	</td>
Also the Save event for the grid is not populating the e.values object per the telerik documentation.