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

[Solved] ActionResult is not called

4 Answers 106 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.
raphael
Top achievements
Rank 1
raphael asked on 06 Oct 2011, 10:55 AM
Hi,

I saw some posts about this problem but i could not find a solution.
I downloaded the package library "Telerik Mvc package" from VS10 because I wanted to test the controls to see how they work, first thing I wanted to try was to do the ajax databinding i copied the code from the telerik help and i got a view that look like that

@model IEnumerable<MvcMovie.Models.Movie>
             
@(Html.Telerik().Grid<MvcMovie.Models.Movie>(Model)
        .Name("grdMovie")
        .Columns( columns =>
        {
            columns.Bound(o => o.Title).Width(100);            
            columns.Bound(o => o.Genre).Width(200);            
        }
        )
        .DataBinding(dataBinding => dataBinding
              //Ajax binding
              .Ajax()
                   //The action method which will return JSON
                      .Select("_AjaxBinding", "Home")
        )
        .Sortable()
)

 

and my controller

namespace MvcMovie.Controllers
{
    public partial class HomeController : Controller
    {
        private MovieDbContext db = new MovieDbContext();
  
        public ActionResult Index()
        {
            var _movie = db.Movies;
            return View(_movie);
        }
  
        //Used for the Ajax binding
        [GridAction]
        public ActionResult _AjaxBinding()
        {
            return View(new GridModel(db.Movies.ToList()));
        }
     }
}


Ok now I debug the project, when the page loads the function that i called is the Index, and even if i try to sort columns or i click the refresh button, the AjaxBinding actionresult is never called.

What am I doing wrong? thank you very much

Raphael

4 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 07 Oct 2011, 08:13 AM
Hi Raphael,

Is there a ScriptRegistrar at the end of the master page? All Telerik UI components need a ScriptRegistrar component in order to output their JavaScript objects and register their JavaScript files. The ScriptRegistrar component should be defined after all other UI components in the page.
 

Kind regards,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
raphael
Top achievements
Rank 1
answered on 07 Oct 2011, 09:14 AM
Hi Georgi,

Ok I didn't read about the script, and it is missing! just a question

should i just use the script on your sample pages

Html.Telerik().ScriptRegistrar()
                     .DefaultGroup(group => group
                     .Compress(true))
                     .OnDocumentReady(() => { %>prettyPrint();<% })
                     .Render();
 or it's better to register all script one by one? in this way?

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

Thank you very much

Raphael
0
Dimo
Telerik team
answered on 07 Oct 2011, 09:35 AM
Hello Raphael,

Using the ScriptRegistrar and the StyleSheetRegistrar will allow you to compress and combine the JS and CSS files, if this is required or appropriate for your application. The registrars can also generate URLs for the Telerik CDN in case you want to use it.

Finally, another useful thing about the ScriptRegistrar is that it registers automatically all script files, depending on the MVC components you have on the page.

Greetings,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
raphael
Top achievements
Rank 1
answered on 07 Oct 2011, 09:44 AM
Hi Dimo,

Thank you for the explanation!
Now the ajax binding works great!

Thank you again for the support

Raphael
Tags
Grid
Asked by
raphael
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
raphael
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or