Currently, the functionality for creating a toolbar template with TagHelpers is not available.
IgnoreCase property is missing for the filterable options of the column:
https://docs.telerik.com/aspnet-core/api/Kendo.Mvc.UI.Fluent/GridBoundColumnFilterableBuilder
The option is documented in:
https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.filterable.ignorecase
I was wanting to create a multiselect filter inside the kendo grid that will filter an array column, NOT a simple string column. Just adding the .Filterable(ftb => ftb.Multi(true)) does display a basic 'multiselect' with just checkboxes in it, which is not ideal , but does work. But, when you click filter, the grid becomes empty. I had to use a clienttemplate() function, to return an html object like so:
export function MultiRowTemplate(data) {
if (data == null) {
return "";
}
var row = "";
for (var i = 0, len = data.length; i <
len
; i++) {
row += data[i].Description + "<br/>";
}
return row;
}
My column is:
columns.ForeignKey(a => a.DisplayExp, (System.Collections.IEnumerable)ViewData["Exp"], "Id", "Description").ClientTemplate("#= MultiRowTemplate(data.DisplayExp) #").Filterable(ftb => ftb.Multi(true)).Title("Experience");
the code for the foreign key doesn't make much sense as it's an array column, but that was pointed to by telerik support on other forum posts.
So, there must be a way to hook into that column and run some custom code to return to the grid the filtered values? i've seen examples for jquery, and mvc, but theres nothing for .net core. This should just work out of the box, as I don't think this is an uncommon need. Could you give me an example or point me in the right direction?
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();
}
}
}
Hi,
We have a property EnableHeaderContextAggregateMenu in Radgrid. By enabling this, we can aggregate any column in the Radgrid and show the result value in the corresponding column footer at runtime by the end user.
Do we have similar property in Kendo UI Grid? We need to implement this in Kendo UI Grid which has dynamic column data binding. We had attached a sample code here. Can you please implement the same in the code and revert?
Thanks & Regards,
Shivakumar. K
I'm currently evaluating the ASP .Net Core Components and whilst I'm liking it so far, I have to say - the documentation leaves a lot to be desired.
At the moment, I am trying to use grid and looking at documentation, I have no idea if I am meant to be looking in Kendo.Mvc.UI.Fluent or Kendo.Mvc.UI - and when I am there and find an item, there just isn't enough detail. In addition, the demos section appears to actually be more helpful and I'm constantly looking there.
What caused me to write this is that I have simply enabled GridFilterMode.Row on an instance and whilst I like it, I want to change the default from "Is Equal To" to "Contains"... I have been experimenting for the past few hours without any luck and I'm going round in circles on documentation:
I can see that Filterable requires GridFilterMode, but the documentation is lacking - https://docs.telerik.com/aspnet-core/api/Kendo.Mvc.UI/GridFilterMode#kendomvcuigridfiltermode
I then try to find the filterable modes documentation, but, half the features/methods just don't seem to have any affect whatsoever.
Personally, I'm having great luck learning about your components from the demo section and adapting the code to suite my needs - but, if there isn't a demo, it appears to be a very hard task to learn what is and isn't possible.
Hi Kendo Team,
I am working on Kendo UI ASP.NET Core Grid binding with SignalR. But while starting Hub and providing the Promise, I am facing an error "The "promise" option must be a Promise."
I am following this URL for reference: https://demos.telerik.com/aspnet-core/grid/signalr .
Checked on your website as well, but the issue is also coming there. Here is the URL: https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.signalr
In this link, when clicking on "Open In Dojo" button, it opens a new window, then clicks on the Run button. It will generate an error in the console "Uncaught Error: The "promise" option must be a Promise.".
Please check the attached snapshot.
Please reply asap. Thanks in advance!
The ability to export a grid to excel has been a great addition, we would like the ability to export in CSV and XML also.