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

[Solved] MVC Grid Model Binding Grid <T> Vs Grid(Model) Query

1 Answer 229 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.
Pradeep N
Top achievements
Rank 1
Pradeep N asked on 27 Apr 2010, 04:31 PM
Hi,
I want client template feature with ajax postback. So i am using as follows.
<%= Html.Telerik().Grid<Order>() 
                 .Name( "OrdersGrid" ) 
        .Columns(colums => colums.Bound(o => o.TransactionNumber)) 
        .Scrollable( scrolling => scrolling.Height( 600 ) ) 
        .Sortable() 
        .Pageable(page => page.PageSize(13)) 
        .Filterable() 
        .Groupable() 
    %> 

My View is a strongly typed view
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Astroved.Web.Shared.Models.Admin.Order>>" %> 

In the controller GetOrderList will return IEnumerable<Astroved.Web.Shared.Models.Admin.Order>
public virtual ActionResult Index() 
        { 
            return View(GetOrdersList()); 
        } 

The items NOT GET BINDED TO THE GRID.
items only get binded when i use as follows
<%= Html.Telerik().Grid(Model) 
                 .Name( "OrdersGrid" ) 
        .Columns(colums => colums.Bound(o => o.TransactionNumber)) 
        .Scrollable( scrolling => scrolling.Height( 600 ) ) 
        .Sortable() 
        .Pageable(page => page.PageSize(13)) 
        .Filterable() 
        .Groupable() 
    %> 

I can't use this since i have to use client template in that. i am advised to use like Grid<T>.

I have used the same procedure for Grid<T> for this and worked out well(Its also a strongly typed view and tried as same as here). I am not sure what i am wrong with.

Thanks In Advance,
Pradeep.





1 Answer, 1 is accepted

Sort by
0
Accepted
IQworks
Top achievements
Rank 1
answered on 28 Apr 2010, 01:10 AM
Hi Pradeep, 
   This might give some ideas ....   
 
        <%= Html.Telerik().Grid(Model)  
              .Name("CompanyGrid")  
                        
               .DataKeys(keys => 
                {  
               keys.Add(o => o.cCompanyNo);  
                })  
                   .DataBinding(dataBinding => 
                          dataBinding.Ajax()  
                   .Select("_AjaxBindingCompany", "Company")  
                   .Delete("CompanyDelete", "Company"))                                 
              .Columns(columns => 
                {  
                       
                    columns.Add(o => o.cCompanyName).Width(185).Title((string)Resources.BCAResources.coxCompany)  
                     .HtmlAttributes(new { @class = "coCompanyNameTT cName" });  
                    columns.Add(o => o.cPhone).Title((string)Resources.BCAResources.stdPhone).Width(75);  
                    columns.Add(o => o.cGroupCode).Title((string)Resources.BCAResources.coxGroupCode).Width(100);  
                    columns.Add(o => o.cEmail).Format(Html.Mailto("{0}", "{0}")).Encoded(false).Width(150);       
                    columns.Add(o => o.cDateUpdated).Format("{0:MM/dd/yyyy}").Width(85).Title((string)Resources.BCAResources.stdUpdated);  
                    columns.Add(o => o.cCompanyNo).Format(Html.ActionLink((String)Resources.BCAResources.stdEdit, "Index", "Work", new { workindex = 2OtherParms = "{0}" }, null).ToString()).Encoded(false).Title("").Width(32).Filterable(false);  
                      
                    columns.Command(commands => 
                    {  
                        commands.Delete();  
                    }).Width(50).Title("Delete");  
                      
                     columns.Add(o => o.cCompanyNo).Width(0)  
                    .HeaderHtmlAttributes(new { style = "display:none" })  
                    .HtmlAttributes(new { @class = "cId" });  
                })  
               .Pageable()  
               .Editable(settings => settings.Enabled(true))  
               .Sortable(sort => sort.SortMode(GridSortMode.MultipleColumn))  
               .Scrollable(scrolling => scrolling.Height(253))  
               .Filterable()   
                       %>    
 
  Check out the .DataBinding and .Select as well.
 
Tags
Grid
Asked by
Pradeep N
Top achievements
Rank 1
Answers by
IQworks
Top achievements
Rank 1
Share this question
or