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

Setting custom command button with odata.

1 Answer 57 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
ddimakis asked on 26 Feb 2015, 01:21 PM

In the following code snippet you see that we are using the MVC Wrapper of kendo ui grid with odata mechanism that gets its data from a controller in server side.
We want to use custom command buttons but we are getting an exception that says that we cannot use custom commands if we are not using server binding. But when we are using odata mechanism with data binding at controller stage, why this is not a server binding ?

Please help.


          .Columns(columns =>
              columns.Bound(c => c.ItemCode);
              columns.Bound(c => c.ItemName);
              columns.Command(command => command.Custom("Details").Text("Details").Action("OpenDetailsForm", "Home")).Width(100);
          .HtmlAttributes(new { style = "height: 380px;" })
          .Selectable(o => o.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
          .Resizable(o => o.Columns(true))
          .Reorderable(o => o.Columns(true))
          .Pageable(pageable => pageable
          .DataSource(dataSource => dataSource
          .Schema(s => s.Total("Total").Data("Data"))
          .Transport(r => r.Read(c => c.Cache(true)).Read(a => a.Action("GetGridDataSource", "Home", new { entityName = typeof(Item).FullName }).DataType("json")))))

1 Answer, 1 is accepted

Sort by
Alexander Popov
Telerik team
answered on 02 Mar 2015, 12:10 PM

Custom commands can be used no matter what the binding mechanism is, however the Action method can be used only with server binding. In the current case I would suggest specifying a Click event handler instead: 
columns.Command(command => command.Custom("Details").Text("Details").Click("myCustomFunction")).Width(100);
Once the button is clicked the myCustomFunction will be called, so you can use it to navigate to the appropriate URL.
On a related note, you can check documentation for the differences between Server and Ajax binding.

Alexander Popov

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question