Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:32:09+00:00 2026-05-29T22:32:09+00:00

I’m trying to use Telerik MVC Grid for an application which requires lots of

  • 0

I’m trying to use Telerik MVC Grid for an application which requires lots of filtering and grouping… On every model I have, it has a property DateTime for storing CreationDate. Sometimes when showing the grid to the user, time isn’t important. Also, I had to use ViewModels to avoid circular references since I’m using LINQ.

The problem comes when resorting or grouping results by date. If I use the CreationDate field as a Datetime on my ViewModel and then give it Format on the View to show only date, it sorts fine, works fine, but when grouping it groups using the whole datetime value, so there wont never be anything groupedby. If I use the CreationDate as a string in the ViewModel, it shows fine the first time but will give error if resorting or grouping by date.

Here’s the code I have for this case:

VIEWMODEL:

    public class CenterViewModel
    {
        public int Id { get; set; }
        public string Name{ get; set; }
        public string CityName { get; set; }
        public string Phone{ get; set; }
        public string CreationDate { get; set; }
        public bool Active { get; set; }
    }

CONTROLLER:

    [GridAction]
    public ActionResult AjaxIndex()
    {
          var model = repository.GetAllRecords()
                    .Select(o => new CenterViewModel
                    {
                        Id = o.Id,
                        Name = o.Name,
                        CityName= o.City.Name,
                        Phone = o.Phone,
                        CreationDate = o.CreationDate .ToShortDateString(),
                        Active = o.Active
                    });

        return View(new GridModel
        {
            Data = model
        });
    }

    public ActionResult Index()
    {
        return View();
    }

VIEW:

   @model IEnumerable<CenterViewModel>

   @(Html.Telerik().Grid<CenterViewModel>()
    .Name("Grid")
    .DataKeys(keys =>
    {
        keys.Add(p => p.Id);
    })
    .Columns(columns =>
    {
        columns.Bound(o => o.Name);
        columns.Bound(o => o.CityName);
        columns.Bound(o => o.Phone);            
        columns.Bound(o => o.CreationDate).Width(200);
        columns.Bound(o => o.Active).Width(100)
    .DataBinding(dataBinding => {
                    dataBinding.Ajax().Select("AjaxIndex", "Centers", null);
    })
    .Pageable()
    .Sortable()
    .Groupable()
    .Filterable())

The above code would work only for the first load of data, when you resort or group by date it will throw the following exception: “Method ‘System.String ToShortDateString()’ has no supported translation to SQL.” which makes sense, but, I think my intention is pretty clear now.

Does anyone know how to solve this issue? Thanks in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:32:10+00:00Added an answer on May 29, 2026 at 10:32 pm

    One thing you could try is in your model to use a date that removes the time element. Then in the view, format the date.

    VIEWMODEL:

    public DateTime CreationDate { get; set; }
    

    CONTROLLER:

    var model = repository.GetAllRecords()
                    .Select(o => new CenterViewModel
                    {
                        Id = o.Id,
                        Name = o.Name,
                        CityName= o.City.Name,
                        Phone = o.Phone,
                        CreationDate = new DateTime(o.CreationDate.Year, o.CreationDate.Month, o.CreationDate.Day),
                        Active = o.Active
                    });
    

    VIEW:

    columns.Bound(o => o.CreationDate).Width(200).Format("{0:MM/dd/yyyy}");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.