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

[Solved] Server Databinding not working

1 Answer 27 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.
Steve
Top achievements
Rank 1
Steve asked on 14 Dec 2011, 09:51 PM

I'm trying to do simple binding on the server side and it doesn't seem to work.  I've used the grid examples as a guideline and tweeked it in many ways.  Nothing seems to get it to call the CustomServerBinding() function, I just get all the data in the table. 

Please note that this is pre-purchase testing that must wrap up by tomorrow.

Here's what I have in the most basic form:

GridTest2.cshtml:

 

@model Domains.TmsEntities
  
@{
    ViewBag.Title = "GridTest2";
}
  
<h2>GridTest2</h2>
  
<div>
@(Html.Telerik().Grid(Model.T_BASE_RSRC)
         .Name("Grid")
         .DataBinding(dataBinding => dataBinding.Server().Select("CustomServerBinding", "Grid"))
         .EnableCustomBinding(true)
         .Columns(columns =>
         {
            columns.Bound(o => o.NAME_NM).Title("Name").Width(170);
         })
         )
           
</div>


GridController.cs:


public class GridController : Controller 
{
        public ActionResult GridTest2()
        {
           return View(new Domains.TmsEntities());
        }
  
        // Never runs the CustomServerBinding() function
        [GridAction(EnableCustomBinding = true, GridName = "Grid")]
        public ActionResult CustomServerBinding(GridCommand command)
        {
           IEnumerable data = (new Domains.TmsEntities()).T_BASE_RSRC.Take(10);
           return View(data);
        }
}


My MVC install was last week and from http://www.telerik.com/account/your-products/trial-product-versions/download-trial-file.aspx?fileid=11861&pid=0&dispkey=True

I've running Win7 64bit, IE 8, & VS 2010, and running in IIS Express.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Dec 2011, 06:00 PM
Hi Steve,

The actual model that is being used to populate the Grid is the one returned by the GridTest2 action method.
Therefore the Grid is being populated with all the data. The CustomServerBinding method will be used if you refresh the Grid or perform some other operation on it.

Greetings,
Daniel
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
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or