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

Column Sorting A-Z

20 Answers 280 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Veteran
Lee asked on 31 Mar 2018, 05:20 AM

Hi,

Not having much luck using this PivotGrid seems it very undeveloped.

How can i sort the Columns from A to Z?

Thanks,
Lee.

20 Answers, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
Veteran
answered on 31 Mar 2018, 05:22 AM

Well, that's silly can't edit a post.

I meant the order of the columns.

For example ATM is displays as:

Overhead, Sick Leave, Annual Leave, Chargeable, RDO, Internal Job

It needs to be in Alphabetical order.

0
Preslav
Telerik team
answered on 03 Apr 2018, 11:24 AM
Hi Lee,

To sort the columns, use an approach similar to the one outlined in the "Sort Dimensions" how-to article:
For a simple example, check my testing Dojo:
I hope this helps.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 04 Apr 2018, 06:15 AM
Thanks, but this doesn't work for the MVC ASP.NET version.....
0
Preslav
Telerik team
answered on 05 Apr 2018, 02:28 PM
Hi Lee,

Indeed, during my tests, I was not able to achieve the desired behavior by using the MVC wrappers. I will need additional time to investigate why there is no sort property in the dataSource definition. Having said that, I will update this forum as soon as I have any further information.

For the time being, you could use the following JavaScript workaround - handle the first dataBound event of the PivotGrid and manually sort it. For example:

<script>
    $(document).ready(function () {
        $("#pivotgrid").data("kendoPivotGrid").one("dataBound", function (e) {
            e.sender.dataSource.sort({ field: "[Product].[Category]", dir: "desc" });
        })
    });
</script>


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 05 Apr 2018, 08:54 PM

Thanks, Preslav.

This also doesn't work with MVC Pivot Grid it has no event 'dataBound'. I'm also use the '.Ajax()'.

Lee.

0
Preslav
Telerik team
answered on 06 Apr 2018, 10:38 AM
Hello Lee,

Generally speaking, the PivotGrid has a dataBound event:
However, here I believe that the problem comes from the fact that you are using AJAX binding. I assume that you are using flat data, please correct me if I am wrong. For the time being, Sorting is supported only in OLAP binding. More information about this is available here:

Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Preslav
Telerik team
answered on 10 Apr 2018, 03:06 PM
Hi Lee,

I am writing in regard to the missing ".Sort" property of the MVC PivotGrid DataSource definition. It appeared that this is a bug, and I logged it here:
As a small token of gratitude for pointing us to this bug, I updated your Telerik points.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Lee
Top achievements
Rank 1
Veteran
answered on 11 Apr 2018, 10:51 AM

Thank you Preslav, whats the normalish turnaround for these types of bugs to get resolved?

Thanks,

Lee.

0
Lee
Top achievements
Rank 1
Veteran
answered on 12 Apr 2018, 08:03 AM
For now i have had to revert to the jQuery version instead of the MVC.
0
Preslav
Telerik team
answered on 12 Apr 2018, 02:19 PM
Hi Lee,

For the time being, I cannot commit to any timeframe when this bug will be fixed. It depends on the severity of the bug, how many of our customers encountered it, etc.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Doug
Top achievements
Rank 1
Veteran
answered on 12 Oct 2018, 01:07 PM
I'm having this issue with the MVC version too.  What's the status of the bug please?
0
Preslav
Telerik team
answered on 15 Oct 2018, 09:15 AM
Hello Doug,

For the time being, our management did not prioritize this bug for fixing.

I raised the priority of the bug in the issue. By doing this, it should be fixed faster.

Please, excuse us for any inconveniences this is causing you.


Regards,
Preslav
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Grace
Top achievements
Rank 1
Veteran
answered on 02 Oct 2020, 12:57 AM

Hi, 

Has this bug been fixed?

0
Preslav
Telerik team
answered on 05 Oct 2020, 02:12 PM

Hello Grace,

I am sorry to say that the bug is not yet fixed.

You can follow its status on the GitHub page - https://github.com/telerik/kendo-ui-core/issues/4145

 

Regards,
Preslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Grace
Top achievements
Rank 1
Veteran
answered on 08 Nov 2020, 01:26 PM

Hi Preslav,

I can see on Github that this bug (https://github.com/telerik/kendo-ui-core/issues/4145) has been fixed in kendo version 2018.1.221    but I can't find a working example. Could you please give me an example of how to apply an initial sort using Kendo MVC pivotGrid?

By the way, I am using kendo 2020.2.617 version

0
Grace
Top achievements
Rank 1
Veteran
answered on 08 Nov 2020, 01:40 PM

 

 

One more thing to mention is that I am using Kendo MVC PivotGrid binding a flat datasource, and trying to sort based on both the columns(area and product) and rows(country and state).

 

@(Html.Kendo().PivotGrid<MyProject.Web.ViewModels.Transaction>()
                           .Name("pivotgrid")
                           //.HtmlAttributes(new { @class = "hidden-on-narrow" })
                           .Filterable(true)
                           .ColumnWidth(65)
                           .Height(585)
                           .DataSource(dataSource => dataSource
                               .Ajax()
                               .Transport(transport => transport.Read(read => read.Action("Transaction_Read", "Home").Data("SearchValues")))
                               .Schema(schema => schema
                                   .Cube(cube => cube
                                       .Dimensions(dimensions =>
                                       {
                                           dimensions.Add(model => model.Product).Caption("Products");
                                           dimensions.Add(model => model.Area).Caption("Areas");
                                           dimensions.Add(model => model.Country).Caption("Countries");
                                           dimensions.Add(model => model.State).Caption("States");
                                       })
                                       .Measures(measures => measures.Add("Quantity Sum").Field(model => model.Quantity).AggregateName("sum").Format("{0:n2}"))
                                   ))
                               .Columns(columns =>
                               {
                                   columns.Add("Area").Expand(true);
                                   columns.Add("Product");
 
                               })
                               .Rows(rows =>
                               {
                                   rows.Add("Country").Expand(true);
                                   rows.Add("State");
                               })                               
                               .Measures(measures => measures.Values("Quantity Sum"))
                           )
                       )
0
Preslav
Telerik team
answered on 10 Nov 2020, 03:39 PM

Hi Grace,

In the issue, the "Environment" version is the version that we used to verify the bug. The bug is fixed in our 2020 R3 SP1 (2020.3.1021) release, so it is not present in the 2020.2.617 build.

To use the fix, update the Kendo version to 2020.3.1021.

Please, give the above a try, and let me know if the fix works for you.

 

Regards,
Preslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Grace
Top achievements
Rank 1
Veteran
answered on 11 Nov 2020, 10:36 AM

Hi Preslav,

I updated kendo to version 2020.3.1021 and it did allow me to apply an initial sort on MVC pivot grid. 

However, I it seems that I can't sort the columns and rows at the same time. 

Below is the ViewModel and the MVC pivotGrid binding Ajax data. How should I sort based on two dimensions?

public class TransactionViewModel
{
    public string Category { get; set; }
    public string Product { get; set; }
    public string Country { get; set; }
    public string State { get; set; }
    public decimal? Quantity { get; set; }
    public int CategorySortOrder { get; set; }
    public int ProductSortOrder { get; set; }
    public int CountrySortOrder { get; set; }
    public int StateSortOrder { get; set; }
     
}

@(Html.Kendo().PivotGrid<MyProject.Web.ViewModels.TransactionViewModel>()
    .Name("pivotgrid")
    .Filterable(true)
    .ColumnWidth(65)
    .Height(585)
    .DataSource(dataSource => dataSource
        .Ajax()
        .Transport(transport => transport.Read(read => read.Action("Transaction_Read", "Home").Data("SearchValues")))
        .Schema(schema => schema
            .Cube(cube => cube
                .Dimensions(dimensions =>
                {
                    dimensions.Add(model => model.Category).Caption("Categories");
                    dimensions.Add(model => model.Product).Caption("Products");                   
                    dimensions.Add(model => model.Country).Caption("Countries");
                    dimensions.Add(model => model.State).Caption("States");
                })
                .Measures(measures => measures.Add("Quantity Sum").Field(model => model.Quantity).AggregateName("sum").Format("{0:n2}"))
            ))
        .Columns(columns =>
        {
            columns.Add("Category").Expand(true);
            columns.Add("Product");
 
        })
        .Rows(rows =>
        {
            rows.Add("Country").Expand(true);
            rows.Add("State");
        })                              
        .Measures(measures => measures.Values("Quantity Sum"))
        .Sort(sort =>
            {
                sort.Add("CategorySortOrder").Ascending();  //We have a specific order requirement for them
                sort.Add("ProductSortOrder").Ascending();
                sort.Add("CountrySortOrder").Ascending();
                sort.Add("StateSortOrder").Ascending();
            }
        )
    )
)

0
Preslav
Telerik team
answered on 13 Nov 2020, 11:07 AM

Hello Grace,

I tested the scenario with the demo from the issue - https://demos.telerik.com/aspnet-mvc/pivotgrid

I modified the code to:

@(Html.Kendo().PivotGrid()
    .Name("pivotgrid")
    .ColumnWidth(200)
    .Height(580)
    .HtmlAttributes(new { @class = "hidden-on-narrow" })
    .Filterable(true)
    .Sortable()
    .Configurator("#configurator")
    .DataSource(dataSource => dataSource.
        Xmla()
        .Columns(columns => {
            columns.Add("[Date].[Calendar]").Expand(true);
            columns.Add("[Product].[Category]").Expand(true);
        })
        .Rows(rows => rows.Add("[Geography].[City]").Expand(true))
        .Sort(sort =>
        {
            sort.Add("[Product].[Category]").Descending();
            sort.Add("[Geography].[City]").Descending();
        })
        .Measures(measures => measures.Values(new string[]{"[Measures].[Reseller Freight Cost]"}))
        .Transport(transport => transport
            .Connection(connection => connection
                .Catalog("Adventure Works DW 2008R2")
                .Cube("Adventure Works"))
            .Read(read => read
                .Url("https://demos.telerik.com/olap/msmdpump.dll")
                .DataType("text")
                .ContentType("text/xml")
                .Type(HttpVerbs.Post)
            )
        )
        .Events(e => e.Error("onError"))
    )
)

The sorting seems to be working on my side:

Having said that, based on the provided information, I am not sure what could be causing the described faulty behavior. Could you please send me a sample project that replicates the issue? I will use this project to fully understand the case, and provide assistance to the best of my knowledge.

I look forward to your reply.

 

Regards,
Preslav
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Grace
Top achievements
Rank 1
Veteran
answered on 15 Nov 2020, 10:10 PM

Hi Preslav,

 

Sorry, you example is binding OLAP data and my question was regarding Ajax binding. Anyway, I've figured out why. The sorting feature of MVC pivotGrid is only available from the latest release 2020.3.1021, and when it sorts, it can only work on the dimension columns other than additional columns. In my situation, I had Category, Country, State and Product as dimensions and tried to sort based on CategorySortOrder etc. PivotGrid doesn't support this kind of sorting, which makes sense considering Kendo is an UI framework so it only 'manipulates' what is actually on the screen. 

 

Thanks,

Grace

Tags
PivotGrid
Asked by
Lee
Top achievements
Rank 1
Veteran
Answers by
Lee
Top achievements
Rank 1
Veteran
Preslav
Telerik team
Doug
Top achievements
Rank 1
Veteran
Grace
Top achievements
Rank 1
Veteran
Share this question
or