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

[Solved] AJAX BINDING Problem

3 Answers 70 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.
Rami
Top achievements
Rank 1
Rami asked on 30 Mar 2012, 07:48 AM
Hi,
i am using telerik grid from past 2 months , i have developed many grids in my project without any problems before.now i am trying to load view when click on other grid. i am able to launch grid in view with partialview and id and there i am using  ajax binding..its always rendering to some other page when ever sorting happend.
url formation is like this way...
http://localhost:3322/viewname/1006?groupId=1006&57a7b24e-e07c-4fc8-aef7-8b6124ebb339=System.Web.Mvc.DictionaryValueProvider%601[System.Object]&grvFinanceMembers-orderBy=HeadOfFamily-asc

how to solve this...

3 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 30 Mar 2012, 08:38 AM
Hi,
57a7b24e-e07c-4fc8-aef7-8b6124ebb339=System.Web.Mvc.DictionaryValueProvider%601[System.Object]  => one of your parameter declaration seam to be incorrect, could you provide some code?
0
Rami
Top achievements
Rank 1
answered on 31 Mar 2012, 11:10 AM
hi
thanks for reply...i have solved that problem...now its not going to some other screen, but its always performing the server side operations when ever performing sorting even though there is  .DataBinding(dataBinding => dataBinding.Ajax().OperationMode(GridOperationMode.Client).Select("actionname", "controllername", new { pageSize = ViewData["pageSize"] }))  .

But in old grids its working fine..i am not able to find out the problem.
how to perform ajax binding...what will be the problem.

0
Dadv
Top achievements
Rank 1
answered on 02 Apr 2012, 08:25 AM
PageSize should not be send as select parameter (telerik grid have is own logic for that).

here a simple explain sample of ajax binding :

Html.Telerik().Grid<Order>() // => No Model give in the Grid method, you need to add the type of the Model instead 
       
.Name("Grid")
       
.Columns(columns =>
       
{
            columns
.Bound(o => o.OrderID).Width(100);
            columns
.Bound(o => o.Customer.ContactName).Width(200);
            columns
.Bound(o => o.ShipAddress);
            columns
.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
       
})
       
.DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Grid")) // => The binding didn't need a lot of thing, //often you only need the action and the controller
       
.Pageable(paging => paging.Style(pagerStyles).Position(position).PageTo(currentPage).PageSize(ViewBag.PageSize)) //if you want the PageSize define, define it here
       
.Sortable()
       
.Scrollable()
       
.Groupable()
       
.Filterable()


In the controller you need 2 methods :
- The "base" action to display the empty grid 
- The ajax datasource to fill the grid

 public ActionResult AjaxBinding()
       
{ ViewBag.PageSize = 20; // define the page size here
           
return View();// no Model passed to the view
       
}
       
[GridAction]//=> don't forget the attribute to tell MVC that you want to let telerik grid address the result
       
public ActionResult _AjaxBinding()
       
{
	    var data = GetOrders();

           
return View(new GridModel<Order> //here we pass a GridModel object that contain the data (IEnumerable), the entire Total row count (int)
           
{
               
Data = data, Total = data.Count()
           
});
       
}

With that you can bind easily the grid.

if you problem is different, please give us some code or, better, a sample project.

Regards,
Tags
Grid
Asked by
Rami
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Rami
Top achievements
Rank 1
Share this question
or