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

[Solved] Bug found? Ajax select url is null

5 Answers 141 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.
Patrik
Top achievements
Rank 1
Patrik asked on 01 Jun 2011, 05:22 PM
Hello!

I use this:
@using ManageMvc.Areas.Community.Models
@using Telerik.Web.Mvc.UI
@model CommunityHelpdeskListViewPage
@{   
    ViewBag.Title = "Community Helpdesk";
    Layout = "~/Views/Shared/TabsLayout.cshtml";
}
 
List with users:<br/>
 
@(Html.Telerik().Grid(Model.CommunityUserList)
        .Name("OrdersGrid")
        .Columns(columns =>
        {
            columns.AutoGenerate(true);
            //columns.Bound(o => o.CountryName);
            //columns.Bound(o => o.Id);           
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("GetUserList", "Helpdesk", new { Search = Model.SearchString, Area = "Community" }))
        .EnableCustomBinding(true)
        .Pageable(paging => paging.PageSize(10))
        .Filterable()
        .Sortable())

This returns the following javascript:
<script type="text/javascript">
 
//<![CDATA[
 
jQuery(document).ready(function(){
 
jQuery('#OrdersGrid').tGrid({columns:[{"title":"Firstname","member":"Firstname","type":"String"},{"title":"Surname","member":"Surname","type":"String"},{"title":"Country","member":"CountryName","type":"String"}], plugins:["filtering"], total:0, currentPage:1, pageSizesInDropDown:["5","10","20","50"], sortMode:'single', ajax:{"selectUrl":null}, noRecordsTemplate:'No records to display.'});});
 
//]]>
 
</script>

As you can see, the ajax url is a null?
Everything else works, the columns are created like they should.

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Jun 2011, 06:12 AM
Hello Patrik,

This could happen if the route is invalid for some reason (controller + action + area + arguments). Is there a chance to attach a sample project which shows this problem?

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
0
Patrik
Top achievements
Rank 1
answered on 03 Jun 2011, 12:44 PM
Hallo Atanas,

Ok, i looked over the routes and added a specific grid route. This is the new route:
(This is from the following file, Areas->Community->CommunityAreaRegistration.cs)

// Create a route for the telerik grid.
context.MapRoute(
    "Community_telerik",
    "Community/Helpdesk/{action}/{command}/{parameter}",
    new { action = "GetUserList", controller = "Helpdesk", command = UrlParameter.Optional, parameter = UrlParameter.Optional },
    new { action = "GetUserList|GetUserPosts" }
);


However it is still generating a null call to the select statement. This is the razor syntax:

@(Html.Telerik().Grid(Model.CommunityUserList)
        .Name("OrdersGrid")
        .Columns(columns => columns.AutoGenerate(true))
        .DataBinding(dataBinding => dataBinding.Ajax().Select("GetUserList", "Helpdesk", new { Area = "Community", Search = Model.SearchString }))
        .EnableCustomBinding(true)
        .Pageable(paging => paging.Total(100).PageSize(10))
        .Filterable()
        .Sortable())

I have also tried to create a routevaluedictionary,
.DataBinding(dataBinding => dataBinding.Ajax().Select(new RouteValueDictionary{{"Action","GetUserList"},{"Controller","Helpdesk"},{"Area","Community"},{"Search",Model.SearchString}}))


The project is way to big to send. I can try to create a new project and see if i can reproduce this.
0
Patrik
Top achievements
Rank 1
answered on 03 Jun 2011, 01:14 PM
Ok, i have created a new project and i get the same error. I have uploaded the project as an attachment.
To test it, run it in visual studio and in the browser type in the following:

http://localhost.... /Community/Helpdesk
0
Georgi Krustev
Telerik team
answered on 06 Jun 2011, 08:45 AM
Hello Patrik,

 
Thank you for the test project.

After further investigation we noticed that the UrlHelper.Action returns null,  because of the "Community_default" route.Grid, internally uses UrlHelper in order to generate correct URLs. After modifying the route, everything starts to work fine. I have attached the modified test project. Check CommunityAreaRegistration.cs file.

Regards,
Georgi Krustev
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
0
Patrik
Top achievements
Rank 1
answered on 08 Jun 2011, 12:47 PM
Hello,

Yea i see now. I changed the telerik route to this instead:
context.MapRoute(
                "Community_telerik",
                "Community/Helpdesk/{action}/{parameter1}",
                new { action = "Index", controller = "Helpdesk", parameter1 = UrlParameter.Optional },
                new { action = "GetUserList|GetUserPosts" }
            );
and now its working as intended. The command parameter that i had previously was not needed for the url postback from my telerik grid.

A suggestion from my point of view would be to define a more cleaner error message, like Invalid Route.

Thank you

Regards
Patrik
Tags
Grid
Asked by
Patrik
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Patrik
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or