This is a migrated thread and some comments may be shown as answers.

Grid Grouping - Null vs Empty String

2 Answers 809 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Veteran
Scott asked on 21 Jul 2016, 05:38 PM

We noticed that when grouping on columns that sometimes have a null and sometimes have an empty string, it will create two different groupings.

I tried to update the ViewModel in MVC so the property always returns an empty string:

public class SampleViewModel
{     
    private string _name;         
   
    [StringLength(50)]
    public string Name     
    {         
        get { return _name ?? string.Empty; }         
        set { _name= value; }     
    }
}

That still produces two different groupings.

How can I get the grid to group these the same way?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 25 Jul 2016, 03:56 PM
Hello Scott,

The grouping in the Grid is by matching values. Since null and empty string are different values, it is by design to have different groups.

I can suggest checking if the null values are correctly converted to an empty string in the Grid data. If client-side grouping is performed, and the data cannot be converted server-side, it is possible to do that client-side, in the schema.parse function:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.parse

You can verify if the data is properly converted server-side by inspecting the server-response.

If you notice an erroneous behavior in Kendo UI and further assistance is needed, please send a runnable example, so we can investigate it.

Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
0
Scott
Top achievements
Rank 1
Veteran
answered on 26 Jul 2016, 05:03 PM

I was able to correct the issue.  The ViewModel rules were too late in the process.  ToDataSourceResult had already done the grouping.

So I added a line before it and this works:

var results = from s in Sample select new SampleViewModel { Name = s.Name ?? string.Empty };                 
return Json(results.ToDataSourceResult(request));

Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Scott
Top achievements
Rank 1
Veteran
Share this question
or