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

[Solved] Grid Ajax Binding issue

3 Answers 135 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.
Amir
Top achievements
Rank 1
Amir asked on 16 May 2011, 04:59 AM
I compared the codes with Telerik sample , everything is the same except the model. But I can't see the records in Grid.
// Controller
 
public  ActionResult Index()
   
{
           
return View();
   
}
   
[GridAction]
   
public ActionResult _Index()
   
{
       
return View(new GridModel<AuctionViewModel>
                   
{
                     
Data = GetData()
                   
}
                   
);
   
}

// If I replace 'Index' Action codes with '_Index' , the server binding works fine and shows the records but when I try to run AjaxBinding , It doesn't works (never runs _Index codes)

// View

   @model List<TestMVC3_Telerik.Models.AuctionViewModel>
   
@{      
   
Html.Telerik().Grid((List<TestMVC3_Telerik.Models.AuctionViewModel>)ViewData["MyAuctions"])
   
.Name("Grid")
   
.Columns(columns =>
   
{
        columns
.Bound(o => o.AuctionID).Title("ID").Width(100);
        columns
.Bound(o => o.AuctionName).Title("Name");
   
})
     
.DataBinding(dataBinding => dataBinding.Ajax().Select("_Index", "Grid"))
   
.Pageable(paging => paging.PageSize(5))
   
.Sortable()
   
.Scrollable()
   
.Groupable()
   
.Filterable();
       
}
When I run above code an empty grid appears. 
 I can change the codes in order to use server binding and it works, but my problem is I can't use Ajax binding.

3 Answers, 1 is accepted

Sort by
0
Artur
Top achievements
Rank 1
answered on 18 May 2011, 08:46 PM
I had a simmilar problem. Try changing
Html.Telerik().Grid((List<TestMVC3_Telerik.Models.AuctionViewModel>)ViewData["MyAuctions"])
to
Html.Telerik().Grid<TestMVC3_Telerik.Models.AuctionViewModel>()
it worked for me.

0
Amir
Top achievements
Rank 1
answered on 19 May 2011, 01:58 AM
I've changed it. It doesn't work ! Any other idea?
0
Ciprian
Top achievements
Rank 1
answered on 06 Aug 2011, 10:53 AM
At this line:
.DataBinding(dataBinding => dataBinding.Ajax().Select("_Index", "Grid"))
try setting the name of your View instead of Grid.

Tags
Grid
Asked by
Amir
Top achievements
Rank 1
Answers by
Artur
Top achievements
Rank 1
Amir
Top achievements
Rank 1
Ciprian
Top achievements
Rank 1
Share this question
or