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: 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