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

[Solved] Custom binding and grouping

5 Answers 510 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.
kalvin
Top achievements
Rank 1
kalvin asked on 21 Jul 2010, 11:31 AM
Hi,
I have problem with implementing custom binding and grouping with telerik mvc grid. i'm not found any sollution how to do that, that is why i made my own sollution, which dosen't work;/ and i really don't know why this is so.

I' using ajax with custom binnding, my method looks like:
[GridAction(EnableCustomBinding = true)]
        public ActionResult _CustomBinding(GridCommand command)
        {
            IQueryable<Person> data = this.PrepareData().AsQueryable();
            
            return View(new GridModel
            {               
                Data = data.GroupBy(x=>x.FirstName),
                Total = this.PrepareData().Count()
            });
 
        }
and view:
<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Pageable(settings => settings.Total((int)ViewData["total"]))
        .DataBinding(dataBinding => dataBinding
             .Ajax()
                         .Select("_CustomBinding", "Defualt")
        )
        .EnableCustomBinding(true)
                .Sortable().Groupable(grouping => grouping
                  .Groups(groups =>
                  {
                      //Group by Country
                      groups.Add(c => c.FirstName);
                  })
    ).Filterable()
%>

or

 
<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .Pageable(settings => settings.Total((int)ViewData["total"]))
        .DataBinding(dataBinding => dataBinding
             .Ajax()
                         .Select("_CustomBinding", "Defualt")
        )
        .EnableCustomBinding(true)
                .Sortable().Groupable().Filterable()
%>

and i see grid without grouping and with white last collumn.

P.S i'm using 2010.1.518.

Regards.

5 Answers, 1 is accepted

Sort by
0
kalvin
Top achievements
Rank 1
answered on 21 Jul 2010, 01:07 PM
Hi,
I've found sollution but it so wired, i had to change
[GridAction(EnableCustomBinding = true)]

on to

[GridAction]

but i'm using enableCustomBinding

http://demos.telerik.com/aspnet-mvc/grid/custombinding?theme=vista look at the description tab, you wrote to use this property on true, but then dosen't work grouping.....

#Edit 1.
Now grouping is worrking but pagging not

Regards
0
Sébastien
Top achievements
Rank 1
answered on 25 Oct 2010, 01:43 PM
Hello,
I have a similar problem. I'm using Custom Binding and my own serailizer (a personal JsonResult, which uses my own serializer, not the default JavascriptSerializer). When a want to group my data, I have an empty column, and not the normal grouping "look" (see the attach file).
I find the error on the JSON result, on the "success" method on telerik.grid.js file. A correct JSON looks like this
{"data":[{"AggregateFunctionsProjection":null,"HasSubgroups":false,"Subgroups":[],"Items":[{"Id":2,"FirstName":"Arnold","LastName":"Schwarzenegger","Sexe":1}],"Key":"Schwarzenegger"},{"Key":"Willis","HasSubgroups":false,"Items":[{"Id":1,"FirstName":"Bruce","LastName":"Willis","Sexe":0},{"Id":3,"FirstName":"Steven","LastName":"Willis","Sexe":1}],"AggregateFunctionsProjection":null,"Subgroups":[]}],"total":3}

But my Json look like this
{"data":[{"Id":1,"FirstName":"Bruce","LastName":"Willis","Sexe":0},{"Id":2,"FirstName":"Arnold","LastName":"Schwarzenegger","Sexe":1},{"Id":3,"FirstName":"Steven","LastName":"Willis","Sexe":1}],"total":3}

Apparently needs some properties like AggregateFunctionsProjection or "Items".

Finally, is it possible to build this object with the classes on the Telerik.Mvc.dll ? I see some classes in the Telerik.Web.Mvc.Infrastructure.Implementation namespace, can I use them and how ?

Thanks
0
Sébastien
Top achievements
Rank 1
answered on 25 Oct 2010, 01:47 PM
Ther's an AggregateFunctionsGroup in the Telerik.Web.Mvc.Infrastructure namesace, which contains apparently all that I need. How can I give this object to the Grid Component ?

Thx
0
Rosen
Telerik team
answered on 25 Oct 2010, 02:12 PM
Hello Sébastien,

Please refer to this forum thread for a sample of possible implementation of custom grouping.

Regards,
Rosen
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
Luis
Top achievements
Rank 1
answered on 07 Jan 2012, 04:05 PM
Finally I got it!

With the help of the guys on this thread I'm proud to say that I came to a satisfactory result, pluggable in any type of MVC application without much difficulty and almost none in the settings.

I published the project on Bitbucket and Nuget, please take a look and send me some feedbacks.

https://bitbucket.org/Lunadie/telerikmvcgridcustombindinghelper/wiki/Home 

https://nuget.org/packages/TelerikMvcGridCustomBindingHelper  
Tags
Grid
Asked by
kalvin
Top achievements
Rank 1
Answers by
kalvin
Top achievements
Rank 1
Sébastien
Top achievements
Rank 1
Rosen
Telerik team
Luis
Top achievements
Rank 1
Share this question
or