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

Kendo Grid, MVC Wrappers, oData WCF Plain

9 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DEX
Top achievements
Rank 1
DEX asked on 22 Feb 2013, 10:22 PM
I trying to hunt down and example on how to wire the Kendo Grid using the uber-awesome MVC Wrappers to call WCF Plain services that I generated from the Telerik OpenAccess rlinq file. I know there are plenty of examples using javascript but my whole website is using the MVC Wrappers and I don't like to have any one-offs - if you know what I mean. Please help.

@(Html.Kendo().Grid(Model)
    .Name("Grid").Sortable().Selectable().Scrollable().Filterable().Groupable()
    .Resizable(c => c.Columns(true))
    .Columns(columns =>
    {
        columns.AutoGenerate(true);
        columns.Command(c => c.Edit());
    })
    .Pageable(pager => pager
        .PageSizes(new int[] { 15, 30, 50, 100 })
    )
    .ToolBar(commands => 
    {
        commands.Create();
        commands.Custom()
            .Text("Clear Filters")
            .Action("Index", "Jobs");
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(m => m.Id(v => v.JOB_TITLE_ID))
        .PageSize(15)
        .Read(read => read.Url("localhost:8082/TrainingService.svc/ReadJOB_TITLEs"))
        .Update(update => update.Action("Edit", "Jobs"))
        .Create(create => create.Action("Create", "Jobs"))
     )
)

9 Answers, 1 is accepted

Sort by
0
DEX
Top achievements
Rank 1
answered on 23 Feb 2013, 01:25 AM
For the record, I also created oData 3 services and still cannot get it to work. Any help would be greatly appreciated.
0
Accepted
Atanas Korchev
Telerik team
answered on 25 Feb 2013, 12:49 PM
Hello Ricky,

 Currently Kendo Grid for ASP.NET MVC can only be bound to an ASP.NET MVC action method. You can find more info in the ajax binding help topic. If you need to use OData or WCF you need to request those services server-side from your action method:

public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
{
    // ProductService is the wrapper of the OData or WCF service.
    var products = ProductsService.GetAll();
     
    DataSourceResult result = products.ToDataSourceResult(request);
 
    return Json(result);
}

The other option is to use the JavaScript-only version of Kendo Grid.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
DEX
Top achievements
Rank 1
answered on 25 Feb 2013, 03:14 PM
The infamous Atanas... hello sir and thanks for getting back to me.

Ok. So server-side it is then. Do you know of any way to tear open the DataSourceRequest so I can send the query strings to the oData service? I would really rather not GetAll() for everything as some of these tables have hundreds of thousands or records.
0
Atanas Korchev
Telerik team
answered on 25 Feb 2013, 04:15 PM
Hello Ricky,

 You can configure your service method to accept paging parameters then pass it the DataSourceRequest properties:

var products = ProductsService.Get(request.Page, request.PageSize);

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
DEX
Top achievements
Rank 1
answered on 25 Feb 2013, 04:18 PM
That's simple enough. But what about the filters, sorts, and aggregates? I tried to create the expressions from the IFilterDescriptor but failed horribly.
0
Atanas Korchev
Telerik team
answered on 25 Feb 2013, 04:27 PM
Hello Ricky,

 I recommend checking the custom binding help example which is available in the ASP.NET MVC sample application. The interesting file is Controllers\Web\Grid\CustomAjaxBindingController.cs

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
DEX
Top achievements
Rank 1
answered on 25 Feb 2013, 04:39 PM
Looks good. I'll try that. Thanks a bunch Atanas.
0
DG
Top achievements
Rank 1
answered on 11 Apr 2014, 05:36 PM
Is there any wrapper to convert a DataSourceRequest  to an oData Uri

I am calling oData from a .Net client and would like to do the following
    DataSourceRequest request = new DataSourceRequest();

            Uri uri = new Uri("http://localhost:61055/odata/");
            var queryUriAll = new Uri("Entity", UriKind.Relative);
            
           I would like to build the following Uri from DataSourceRequest
             var queryUriAllinline = new Uri("Member?$top=2&$skip=1&$inlinecount=allpages", UriKind.Relative);
            var container = new oDataServiceReference.Container(uri );
            
            var entity = container.Execute<MemberServiceReference.Entity>(queryUri).ToList();
            var dataResult = entity.ToDataSourceResult(request); 
0
Atanas Korchev
Telerik team
answered on 14 Apr 2014, 07:06 AM
Hello Douglas,

Currently there is no built in code which will convert a DataSourceRequest to an OData Uri.

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
DEX
Top achievements
Rank 1
Answers by
DEX
Top achievements
Rank 1
Atanas Korchev
Telerik team
DG
Top achievements
Rank 1
Share this question
or