Sorting when all values are equal

2 posts, 0 answers
  1. Kjell
    Kjell avatar
    275 posts
    Member since:
    Jun 2010

    Posted 16 Feb Link to this post

    Hi, I know this is maybe a strange question but I'd like to inquire about the behavior when sorting on a column where all values are the same.  I would expect that nothing changes, however that is not the case,  rows seem to sort randomly.  What sort is being applied in this case?  The interesting thing is I have two columns like that, and they both get sorted in the exact same order, so there is some logic I just can't tell what it is.  The behavior should be that if column values are all the same no sort is applied (this is how the silver light grid which I'm migrating from works). 
  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 18 Feb Link to this post

    Hi,

    I have tested the following setup on my end but did not experience the described behavior.

    View:
    @(Html.Kendo().Grid<GridCustomPopupTemplate.Models.Person>().Name("persons")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Batch(true)
            .Model(model => model.Id(m => m.PersonID))
                .Read(read => read.Action("GetPersons", "Home"))
        )
     
        .Columns(columns =>
        {
            columns.Bound("PersonID");
            columns.Bound("BirthDate");
            columns.Bound("Name");
        })
        .Sortable()
    )

    Controller:
    public static List<Person> persons = new List<Person>();
     
    static HomeController()
    {
        persons.Add(new Person { PersonID = 12, Name = "John", BirthDate = new DateTime(1968, 1, 26) });
        persons.Add(new Person { PersonID = 11, Name = "John", BirthDate = new DateTime(1974, 2, 13) });
        persons.Add(new Person { PersonID = 10, Name = "John", BirthDate = new DateTime(1968, 3, 26) });
        persons.Add(new Person { PersonID = 9, Name = "John", BirthDate = new DateTime(1968, 4, 26) });
        persons.Add(new Person { PersonID = 8, Name = "John", BirthDate = new DateTime(1968, 5, 26) });
        persons.Add(new Person { PersonID = 7, Name = "John", BirthDate = new DateTime(1968, 6, 26) });
        persons.Add(new Person { PersonID = 6, Name = "John", BirthDate = new DateTime(1968, 7, 26) });
        persons.Add(new Person { PersonID = 5, Name = "John", BirthDate = new DateTime(1974, 8, 13) });
        persons.Add(new Person { PersonID = 4, Name = "John", BirthDate = new DateTime(1974, 9, 13) });
     
        persons.Add(new Person { PersonID = 3, Name = "John", BirthDate = new DateTime(1974, 10, 13) });
        persons.Add(new Person { PersonID = 2, Name = "John", BirthDate = new DateTime(1974, 11, 13) });
        persons.Add(new Person { PersonID = 1, Name = "John", BirthDate = new DateTime(1974, 12, 13) });
    }
     
    public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to kick-start your ASP.NET MVC application.";
     
        return View();
    }
     
    public ActionResult GetPersons([DataSourceRequest] DataSourceRequest dsRequest)
    {
        var result = persons.ToDataSourceResult(dsRequest);
        return Json(result);
    }

    Can you please share with us the problematic code so we could examine the implementation? Additionally please elaborate on the exact version of the controls used in the project.

    Regards,
    Angel Petrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top