Completed
Last Updated: 22 Apr 2020 16:18 by ADMIN
Release 2.11.0
devon
Created on: 03 Oct 2019 08:14
Category: Grid
Type: Feature Request
43
Support for nested (complex) models

ADMIN EDIT: The following knowledge base article has been updated to explain how to use nested models: https://docs.telerik.com/blazor-ui/knowledge-base/grid-bind-navigation-property-complex-object

 

At the moment, you must use flat models with primitive types for binding the grid. If you don't, the data source operations break and they can't even display "nested" values. Examples here and here.

I would like to be able to use my complex models so I can point a grid's column to a field like MyModel.MyNestedModel.MyPrimitiveField

My be related to binding to a data table and dynamic expando.

17 comments
ADMIN
Marin Bratanov
Posted on: 22 Apr 2020 16:18

Hi all,

This feature is already available in our 2.11.0 release that just went out. The following KB article was updated to explains how nested models work: https://docs.telerik.com/blazor-ui/knowledge-base/grid-bind-navigation-property-complex-object

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
ADMIN
Marin Bratanov
Posted on: 14 Apr 2020 12:25

We are aiming at the end of the month, maybe even a little earlier. Hopefully, by the end of next week. We depend a lot on how Microsoft release the Preview4 version of WASM.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
cilerler
Posted on: 14 Apr 2020 12:22
This is great news, thank you! Any idea when it will be released?
Ben Hayat
Posted on: 14 Apr 2020 11:40
Thank you team for this feature.
ADMIN
Marin Bratanov
Posted on: 20 Mar 2020 13:01

Hello,

At the moment, the tentative plan is mid-May. You can click the Follow button on the page to get email notifications for status updates.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
cilerler
Posted on: 12 Mar 2020 13:48
Any time frame about when this feature will be on EAP?
ADMIN
Marin Bratanov
Posted on: 11 Jan 2020 10:06

Thank you, Robert, for taking the time to provide such a great summary of your experience, and for your kind words. I appreciate it and I will make sure the dev team and the management sees it as well.

While a lot of scenarios require a lot of advanced features, there are actually even more cases when a few basic things are only needed. In many cases a unified look is very important, and that's also one of the key reasons why we need to create those other "unnecessary" components - they are usually building blocks that make an application look sleek and complete, as opposed to put together quickly. It's more about the perception the end user will get and the unified theming rather than us providing functionality that does not exist anywhere else with those "simple" components. In turn, they are then also reused in more complex components we make.

What I am getting at is that there are many ways to reason a decision, and we receive requests and feedback for all of them. Anything I will say at this point will keep sounding like an excuse, even if it is a piece of candid truth, so I will end this post by confirming again that we intend to look into this.

Regards,
Marin

 

Robert McLaws
Posted on: 10 Jan 2020 17:55

So there are a few points I want to bring up. But first I want you to understand that I respect you folks and the work that you're doing. I've been following this stuff since the very beginning, as I was a very early Kendo customer and former Kendo Developer Champion and Certified Expert.

1) I've spent hundreds of hours with Telerik controls, and had to build dozens of workarounds for features that were not very well thought out or partially implemented. You folks could get away with that when the controls were Javascript, and you could just overwrite buggy methods with better functionality. That's not an option here, so the team needs to think differently.

2) Radzen was started by one of the original Kendo UI devs. He was able to figure this problem out, and his team is really small. So it's hard to take the "it's complicated" reasons very seriously. It's not a Blazor Core bug that no one can work around, other people have figured it out... they just built it the right way from the beginning. So your customers aren't going to really want to hear excuses. 

3) Part of the problem is that you folks are doing the same thing you've been doing for a decade, which is the "mile-wide, inch deep" principle of component development. You've got all these controls, and they all only do a small fraction of what people actually need. Like, why the heck did you folks build a Button control? Or a Textbox? These things have HTML5 equivalents, that's wasted engineering time. You folks have a Grid control that has LOTS of functionality, but can only handle the most basic of data structures.

And because you went mile wide, now you have to rewrite a bunch of the internals because the team didn't think you'd want to build tables with complex relationships. But WAIT! There's a TabStrip! Never mind you can already do that in Bootstrap or Foundation or any of the other layout frameworks you're likely to be using.

I'm being a little sarcastic to make a point. You folks make the best Blazor controls out there, bar none. And yet, right now I'm using a free competitor from one of your original employees. Because your Grid control has every feature you can possibly want... except for one of the most basic features it actually needs. So as one of your early beta testers, I had to rip Telerik.Blazor out of my projects... and six months later, the problem is still not fixed.

Don't make excuses. No one wants to hear how hard your job is, we're all developers with hard jobs. Just figure it out, and tell us when we can expect it to be done. And understand, the more unnecessary controls you build before that happens, the slower your adoption will be (and the less money the Blazor tools will make).

Just my $0.02.

ADMIN
Marin Bratanov
Posted on: 10 Jan 2020 17:23

Hi Robert,

I have already raised the priority of this task as much as possible internally. The entire Blazor suite has been in development for less than a year, and it is bound to have a lot of "big rock" type of features that will still need to be implemented even though they are blockers for some projects. We've already created about 30 native components from scratch (suites that are a decade old often don't reach 100 components) and our next release will also bring a ton of accessibility features, which are also a must.

This particular one is not as trivial as it seems at first glance - reading the name of the field is the easiest part. Then, we must ensure that a lot of other features can work with that, including things like editing, grouping, filtering, and so on, and all of them rely on the field as a reference and type, not just as a string name, so the needed code changes may be rather extensive. This, combined with the lack of any stable testing environment for Blazor makes such things cumbersome, and they do take time.

All that said, I want to assure you again that this enhancement has our attention.

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Robert McLaws
Posted on: 10 Jan 2020 15:42

System.Linq.Dynamic.Core comes from this repo: https://github.com/StefH/System.Linq.Dynamic.Core. So if you don't want to take the dependency, then pull the required code into the Telerik.Blazor assembly.

Either way, you should consider bumping up the priority on this. I helped roll out the Kendo Grid for Florida government .NET apps, and they now have over a dozen apps using it. They are considering moving to Blazor, but they would not even think about it if this issue remains unfixed.

ADMIN
Marin Bratanov
Posted on: 10 Jan 2020 10:08

Thank you for sharing your feedback, experience and the code.

We have this in our sights and we will be working on this task as soon as we can, although we would probably have to not use third party dependencies to get it done.

Please click the Follow button to get email notifications for status updates on it, and I've also added your Vote for you, which is a measure of increasing the priority of the task (we do monitor the community feedback and the popularity of the individual requests in order to prioritize).

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Robert McLaws
Posted on: 10 Jan 2020 04:48

Telerik Employees: This is actually super-easy to implement. Radzen's Blazor components support it using the System.Linq.Dynamic.Core NuGet package. It's relatively straightforward to turn a string into a navigatable lambda. 

You can also guarantee type safety by using lambdas for deep property navigation, like this:

        <TelerikGridColumn TItem="CompanyEmployee" Property="@(NameOf.Full<CompanyEmployee>(c => c.Team.DisplayName))" Title="Team Name" Width="200px">

Since I'm nice, I'll even give you the source code for the NameOf function, so that you can implement this in the product:

using System;

using System.Linq.Expressions;

namespace Telerik.Blazor
{

    /// <summary>
    /// Fills a gap in <see langword="nameof" /> by allowing you to use deep name references instead of local name references.
    /// </summary>
    /// <remarks>
    /// Solution modified from <see href="https://stackoverflow.com/a/58190566/403765" />.
    /// </remarks>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "<Pending>")]
    public static class NameOf
    {
        #region Public Methods

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static string Full<TSource>(Expression<Func<TSource, object>> expression)
        {
            Ensure.ArgumentNotNull(expression, nameof(expression));

            var memberExpression = expression.Body as MemberExpression;
            if (memberExpression == null)
            {
                if (expression.Body is UnaryExpression unaryExpression && unaryExpression.NodeType == ExpressionType.Convert)
                    memberExpression = unaryExpression.Operand as MemberExpression;
            }

            var result = memberExpression.ToString();
            result = result.Substring(result.IndexOf('.') + 1);

            return result;
        }


        /// <summary>
        /// Allows you to create a source name expression when you need to have a prefixing variable in the result.
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="sourceFieldName"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static string Full<TSource>(string sourceFieldName, Expression<Func<TSource, object>> expression)
        {
            var result = Full(expression);
            result = string.IsNullOrEmpty(sourceFieldName) ? result : sourceFieldName + "." + result;
            return result;
        }

        #endregion
    }

}

Hope that helps implement the feature... it's a dealbreaker for pretty much anyone without it.

ADMIN
Marin Bratanov
Posted on: 06 Jan 2020 17:35

Hello Brian,

At the moment, flattening the model like that is the only way to do this.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Brian
Posted on: 05 Jan 2020 06:17

I am working with GIS data from an API, and by its nature it is complex.  Here is a simplified version of the JSON POCO I serialize to:

public class Address {
   public string StreetNumber;
   public string StreetName;
   public string FreeFormAddress;
}

public class Poi {
  public string Name;
  public string Category;
}

public class Result {
  public Address Address;
  public Poi Poi;
}

public class GIS {
  public Summary Summary;
  public IList<Results> Results
}

I get the json back, serialize it into the object, and then I want to display GIS.Results[x].Poi.Name, GIS.Results[x].Poi.Category, and GIS.Results[x].Address.FreeFormAddress in a Grid.  The nameof() does not produce qualified names, just the last property (Name, Category, and FreeFormAddress).  This is a limitation of nameof(), not Telerik.  Other Competitor products have the same issue.  

Issue 1 is the nested (complex) objects.  Issue 2 is the Ilist array within.  My question is the following solution the best approach?

For #1, the nameof() issue, I added Getters into Results to flatten the object:

public class Results {
   ....
   public string Name { get { return Poi.Name; } }
   public string Category { get { return Poi.Categories; } }
   public  string FreeformAddress { get { return Address.FreeformAddress; } }
}

For #2,

   public Ilist<Results> DataSource; 

Then 

    protected override void OnParametersSet()
    {
        base.OnParametersSet();
        if (GIS!= null)
        {
            DataSource = GIS.Results;
        }
    }

And then I set the grid as

            <TelerikGrid Data="DataSource"
                             SelectionMode="GridSelectionMode.Single"
                             @bind-SelectedItems="SelectedItems">
                <GridColumns>
                    <GridColumn Field="@nameof(Results.Name)" />
                    <GridColumn Field="@nameof(Results.Category)" />
                    <GridColumn Field="@nameof(Results.FreeformAddress)" />

                </GridColumns>
                </TelerikGrid>

It works, works fine, especially for a small set of columns.  But is this the best way?  Is there anything I'm missing?

TIA

cilerler
Posted on: 05 Dec 2019 16:16

This feature is literally a show stopper for me at this point.

ADMIN
Marin Bratanov
Posted on: 22 Oct 2019 12:11

Hi Ian,

The component suite is very young and does not offer all the features we have in suites that are a decade (or sometimes a lot more) old. We are constantly working on adding new features and supporting new scenarios, and this one is in our sights.

To get notifications when work is done on it, just click the Follow button at the top of the Feedback Portal page.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
ian
Posted on: 22 Oct 2019 11:45
I find this disappointing as it runs counter to the notion that the Telerik components offer a way of speeding up development. My requirement is only to display the results in the same way that is achieved with a HTML grid only faster.