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

Using Grid with Spark partials

1 Answer 48 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.
critto
Top achievements
Rank 1
critto asked on 08 Mar 2010, 10:48 AM
Hi.

I'm currently trying to host a Grid in a spark partial and bind it to an ajax request for data. I'm getting a 404 when my grid calls the controller/action. 

This is my controller action:

    [AcceptVerbs ( HttpVerbs.Get)]
    [GridAction ( EnableCustomBinding = true )]
    public ActionResult _AjaxAllergyBinding ( )
    {
      return View ( new GridModel<AllergyRecordEntity>
      {
        Data = _repository.GetAllergyRecords ( CurrentUser.SelectedPatient ).ToList(),
        Total = _repository.GetAllergyRecords ( CurrentUser.SelectedPatient ).ToList ( ).Count
      } );
    }


This is my Grid code in the spark partial:

 <viewdata allergies="IEnumerable[[AllergyRecordEntity]]" />

<div class="recordblock">
    <% 
    Html.Telerik ( ).Grid<AllergyRecordEntity> ( allergies )
 .Name ( "Allergies" )
 .Columns ( columns =>
 {
// -> Html helper retrieves column title text using culture and static list class
columns.Add ( x => x.Allergen ).Title ( Html.GetResourceText ( CultureString , TranslateText.Allergen ) );
columns.Add ( x => x.Symptom ).Title ( Html.GetResourceText ( CultureString , TranslateText.Symptom ) ).Format ( "{0:dd/MM/yy}" );
columns.Add ( x => x.Specialist.NameDetail ( ) ).Title ( Html.GetResourceText ( CultureString , TranslateText.Doctor ) );
 } )
        .Ajax ( settings => settings.Action ( "_AjaxAllergyBinding" , "Allergy" ) )
        .Pageable ( settings => settings.Total ( ( int ) ViewData [ "total" ] ) )
        .EnableCustomBinding ( true )
        .Sortable ( )
        .Render ( );
    %>
</div>

The error is stating:  Error! The requested URL "/Allergy/_AjaxAllergyBinding" returned 404 - Not found

The page is first loaded from it's parent page with a list of objects and the grid is populated. When clicking the refresh button in the bottom left corner, I get the error. The controller action isn't hit on debug either. 

Is there something I am missing?

Cheers,

H.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Mar 2010, 11:17 AM
Hi hamish crittenden,

The problem is that the grid is making POST requests when calling the ajax action method. Either remove the AcceptVerbs attribute from your controller or change HttpVerbs.Get to HttpVerbs.Post.

Regards,
Atanas Korchev
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
Grid
Asked by
critto
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or