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

[Solved] ClientTemplate href JSON error

1 Answer 62 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.
Richard
Top achievements
Rank 1
Richard asked on 03 Aug 2010, 04:23 PM
Hi

I made this code, and i can't find where is the error.


The view:
<%
 .Grid<GridDemoMvc.Models.viewWebReport_CompliantUsage>()
            .Name("Grid")
            .DataBinding(dataBinding => dataBinding
                .Ajax()
                .Select("CompliantUsage_Select", "CompliantUsage")
            )
           .Columns(c =>
            {
                  c.Bound(o => o.Vendor)
.ClientTemplate("<a href='" + Url.Content("/IPC/IPC/") + "<#= Vendor #>/" + "'><#=Vendor#></a>").Title("a");
                  c.Bound(o => o.Vendor).ClientTemplate("<a href=\"/IPC/IPC/" + "<#=Vendor#>" + "\">" + "<#=Vendor#>" + "</a>").Encoded(false).Title("b").HtmlAttributes(new { @class = "ihover ReceivedMemos" });
            c.Bound(o => o.Product).ClientTemplate("<a href=\"/IPC/IPC/" + "<#=Product#>" + "\">" + "<#=Product#>" + "</a>").Encoded(false).Title("c").HtmlAttributes(new { @class = "ihover ReceivedMemos" });
                
}
 
 
            )
 
            .Pageable(paging =>
                paging.PageSize(20)
                .Style(GridPagerStyles.NextPreviousAndNumeric)
                .Position(GridPagerPosition.Bottom)
             )
              
               
        
            .Sortable()
             
            .Filterable()
            .Groupable()
  .ClientEvents(events => events.OnDataBound("onDataBound"))

            .EnableCustomBinding(true)
            .Render();
         %>
              
The controller:
   public ActionResult CompliantUsage()
   {
     return View(GetCompliantUsage());
 
      
   }
 
 
    private IEnumerable<viewWebReport_CompliantUsage> GetCompliantUsage()
    {
      DataClasses1DataContext northwind = new DataClasses1DataContext();
      return northwind.vW_CompliantUsages;
 
    }
 
[GridAction]
   public ActionResult CompliantUsage_Select()
   {
 
     return View(new GridModel
     {
       Data = GetCompliantUsage()
     });
 
   }

If i use these code in Firefox or Chrome, it's works, but if i click the link, or refresh page i get alert, with this text:
"Error! The requested URL did not return JSON,".

If i want use these code in IE or Opera the links are dead.
I use 2010.2.713 release, but i tried this with 2010.1.416 and 2010.1.518 too, but still not good.

If you have any idea please share with me.

P.S.: I tried server binding , but i can't set sorting and filtering if i use Template, so i have to do it with AjaxBinding

Thx

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 03 Aug 2010, 10:23 PM
Hi

The problem was here:

<script type="text/javascript">
  
             function onDataBound() {
  
                 var grid = $(this).data('tGrid');
                 grid.ajaxRequest();
               }
  
               
</script>

grid.ajaxRequest() was the source of error. The links are works now


Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or