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

Columns not sorting

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 19 Nov 2016, 09:54 PM

Requirements

Telerik Product and Version

2014.3.1411.440

Supported Browsers and Platforms

GoogleChrome

Components/Widgets used (JS frameworks, etc.)

UIGrid


PROJECT DESCRIPTION 
[enter description here, together with step-by-step instructions on how to use the project]
We have several pages where we have noticed that the sorting of the grid is not working. We are attempting to sorty by four columns but to no luck we are able to get the desired results.. Attached is a sample of the binding as well as the controller method that retrieves the method.

I have tried binding it both in the controller using OrderBy, ThenBy extensions as well as the sort in the grid binding. Additionally I have also sorted the results within the method that the controller calls and have reviewed it with LinqPad and it appears to be sorting correctly. However I cannot get it bind sorted in the grid. Any help will be appreciated.

Grid Binding

Scrollable(a => a.Height("auto"))
                  .Sortable()
                  .PrefixUrlParameters(false)
                  .Filterable()
                  .Pageable(pageable => pageable
                      .Refresh(true)
                      .PageSizes(new[] { 50, 100, 250, 500, 1000 })
                      .Messages(messages => messages.ItemsPerPage(" items are currently displayed"))
                      .ButtonCount(5))
                  .DataSource(dataSource => dataSource
                      .Server().PageSize(250)
                      .Sort(s =>
                          {
                              s.Add(c => c.EAN).Ascending();
                              s.Add(c => c.IngramSku).Ascending();
                              s.Add(c => c.BusinessYear).Descending();
                              s.Add(c => c.BusinessMonth).Descending();                             

 

Controller Method Logic

var viewModel = new ViewModels.RAM.VendorQuarterlyRevenueViewModel()
           {
               VendorId = vendorId,
               VendorName = GetVendorName(vendorId),
               sort = sort,
               filter = filter,
               group = group,
               ShowDataGrid = true,
               ReportDate = new ViewModels.RAM.ReportDateViewModel()
               {
                   BeginDate = beginDate,
                   EndDate = endDate,
                   MaxDate = maxDate,
                   MinDate = minDate,
               },
               VendorQuarterlyRevenueData = _ramReportRepository.GetVendorQuarterlyRevenue(_ramReportRepository.GetContext(), beginDate, endDate, vendorId)
           };
 
           if (dataSourceRequest.Filters != null)
           {
               viewModel.VendorQuarterlyRevenueData = (IQueryable<VendorRevenueModel>)viewModel.VendorQuarterlyRevenueData.Where(dataSourceRequest.Filters);
           }
 
 
           foreach (var item in viewModel.VendorQuarterlyRevenueData)
           {
               viewModel.FreightRevenueSum += item.FreightRevenue;
               viewModel.NetSalesSum += item.NetSales;
               viewModel.RentalIncomeSum += item.RentalIncome;
           }
 
 
           return View("VendorQuarterlyRevenueReport", viewModel);

 

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 23 Nov 2016, 02:44 PM
Hello Brian,

So you confirm that sorted results are returned to the view, but the grid shows them in different order?
Do you perform any logic client side, that can affect the sorting?

Regards,
Vasil
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or