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

[Solved] AjaxBinding paging problem with ActionLink

4 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ani Jalan
Top achievements
Rank 1
Ani Jalan asked on 29 Dec 2009, 07:07 PM
I have a grid which is Ajax bound. One of the columns is an ActionLink.
I am not able to page (it just hangs). The first page renders fine. may paging works if I remove this column.

View:
    <%= Html.Telerik().Grid(DataHelper.GetSearchList(ViewData))
            .Name("SearchList")
            .Columns(columns =>
             {
             columns.Add(o => o.Id).Format(Html.ActionLink("{0}", "View", "SearchGUI", new { Id = "{0}" }, null).ToString()).Encoded(false).Title("Id");
             columns.Add(o => o.AddedBy);
             })
           .Ajax(ajax => ajax.Action("AjexBinding", "Search"))
           .Pageable(pager => pager.PageSize(30).Style(GridPagerStyles.Numeric))

Controller:
        [GridAction]
        public virtual ActionResult AjexBinding()
        {
            IEnumerable<TItem> dataItems = Session[ListSessionKey] as IEnumerable<TItem>;
            if (dataItems == null)
            {
                dataItems = new TItem[0];
            }
            return View(new GridModel<TItem> { Data = dataItems });
        }



4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Dec 2009, 10:37 AM
Hello Ani Jalan,

Have you included a ScriptRegistrar after your grid? This is mandatory as the script registrar outputs the JavaScript required to perform ajax paging.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ani Jalan
Top achievements
Rank 1
answered on 31 Dec 2009, 12:59 PM
yes I have the ScriptRegistrar.
As I said everything works if I remove the ActionLink column.

My workaround at this point is to not use actionLink but format the action link in one of the properties of Model.
0
Atanas Korchev
Telerik team
answered on 31 Dec 2009, 04:21 PM
Hi Ani Jalan,

Do you see any JavaScript erros when this problem occurs? If yes could you please let us know what the error message says?

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Vincent Girard
Top achievements
Rank 1
answered on 08 Jan 2010, 09:00 PM
Hi Ani,

First thanks for posting youre code, I was looking for a way to add an action link to the grid and youre code work just fine for me. I'm replying because even the paging works fine.

So I'm posting my code, maybe you could find the difference, I'm using all the latest versions :

<%= Html.Telerik().Grid<CustomerCfms>() 
                .Name("Grid") 
                .Columns(colums => 
                 { 
                     colums.Add(c => c.FirstName).Title("Prénom"); 
                     colums.Add(c => c.LastName).Title("Nom"); 
                     colums.Add(c => c.Phone1).Title("Téléphone"); 
                     colums.Add(c => c.IsCommercial).Title("Commercial"); 
                     colums.Add(c => c.City).Title("Ville"); 
                     colums.Add(c => c.Id).Format(Html.ActionLink("Modifier", "Edit", "CustomerCfms", new { Id = "{0}" }, null).ToString()).Encoded(false).Title(""); 
                 }) 
                .Ajax(a => a.Action("ListCustomersAjax", "CustomerCfms")) 
                .Pageable(p => p.PageSize(5).Style(GridPagerStyles.NextPreviousAndNumeric)) 
                .Sortable() 
                .Scrollable() 
        %> 

Good luck!
Tags
Grid
Asked by
Ani Jalan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Ani Jalan
Top achievements
Rank 1
Vincent Girard
Top achievements
Rank 1
Share this question
or