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

[Solved] Telerik Grid Headache

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ahmed Ilyas
Top achievements
Rank 1
Ahmed Ilyas asked on 13 Sep 2011, 08:30 PM
Hi.
using MVC 2.0 here.
We have a Controller. This controller has invoked from different views but also partial views.

I have a class (somewhat a view helper) which has 2 properties. One is an IEnumerable<T> and the other property is just a singular entity.

Got the GridControl to bind the IEnumerable<T> items fine.
The ordering (sorting) of the collection is done at the Action (server) end like so:

viewHelper.Pubs = pubs.OrderByDesending(p => p.CreatedAt)..... you see how it is.
This then is returned to a View, which has a partial view.
The partial View directly gets this model/helper passed into it.

The Grid control binds it.
Problem: When we say go to a row/record to view more details about that item, then when we hit back on the browser - the items on the grid are no longer ordered and for some bizarre reason, somewhere, a few more items are being added into the control somehow.

There is nothing "fancy" going on behind the scenes apart from obtaining a collection of entities (and ordering them by the CreatedAt field in DESC), and another entity - putting these 2 into a ViewHelper as 2 properties.

This really has been giving me a headache all day today and no idea where to go.

Any ideas are appreciated. It just doesnt make sense why the grid decides to ignore the model it has been given in the correct order. Even performing the Ordering on the grid itself does not make any difference.

There is also NO ajax databinding going on.

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 14 Sep 2011, 09:40 AM
Hello Ahmed Ilyas,

I'm afraid that the provided information is not sufficient in order to track the cause the behavior you have described. Therefore, could you please provide a small runnable sample in which this can be observed.

All the best,
Rosen
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Ahmed Ilyas
Top achievements
Rank 1
answered on 14 Sep 2011, 10:05 AM
Sure, no problem. I should have done that.

It's a big system so ill do my best to post a small sample... but im sure you would get the jist of it:

Controller:

public ActionResult ServicePublication(Guid id)
{
            IService service = _controllerService.FindServiceById(id);
           
            ICollection<IPublicationItem> pubItemsForService = this._publicationItemService.FindByServiceId(id).ToList().AsReadOnly();
           
            IEnumerable<IPublication> pubs = pubItemsForService.Cast<PublicationItem>().Select(x => x.Publication).Cast<IPublication>().OrderByDescending(p => p.CreatedAt).ToList();
           
            var viewHelper = new ServicePublicationViewResultHelper
                                                                {
                                                                    Publications = pubs,
                                                                    Service = service
                                                                };

            return View(viewHelper);
}



View:
<div>
        <% Html.RenderPartial("ServicePublicationList", Model); %>
</div>


ServicePublicationList:

<%= Html.Telerik().Grid(Model.Publications)
        .Name("ServicePublicationsGrid")
        .DataKeys(keys => keys.Add(x => x.Id))
        .Columns(columns =>
        {
            columns.Template(x => x.CreatedAt).Title("Published");

            columns.Bound(x => x.Id).Format(Html.ImageActionLink("../../Content/LinkImage.png", "", "ActionNameHere", "ControllerNameHere", new { id = "{0}", serviceId = Model.Service.Id }, null)).Encoded(false).Title("").Width(16).Sortable(false).Filterable(false);
        })
            .Pageable()
            .Sortable()
            .Filterable()
%>


hopefully this should be sufficient enough.

0
Rosen
Telerik team
answered on 14 Sep 2011, 02:54 PM
Hi Ahmed Ilyas,

I'm afraid that the code you have pasted looks ok to me. Therefore, a small sample which demonstrates the issue will be appreciated.

Regards,
Rosen
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Ahmed Ilyas
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Ahmed Ilyas
Top achievements
Rank 1
Share this question
or