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

[Solved] ToolBar.Template

3 Answers 150 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.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 09 May 2011, 03:09 PM
We have a Telerik MVC 3 Razor Web App.
In on eof the views we have a Grid and would like to add a Combobox in de Toolbar.

I've looked at the Toolbar template Demo but am not able to get this working.

My code looks like below. When i run the app i get the following error : CS1502: The best overloaded method match for 'Telerik.Web.Mvc.UI.Fluent.GridToolBarCommandFactory<Web.Models.OrderViewModel>.Template(System.Func<object,object>)' has some invalid arguments

I probably have the syntax for the toolbar wrong but i'm not sure.
Can anybody see what's wrong with the code?


@(Html.Telerik().Grid<Web.Models.OrderViewModel>()
    .Name("OrdersGrid")
    .ToolBar(toolBar => 
        toolBar.Template(
            @Html.Telerik().ComboBox()
                .Name("StateComboBox")
                .Items(item =>
                {
                    item.Add().Text("Alle orders").Value("1");
                    item.Add().Text("Afgekeurde orders").Value("2");
                    item.Add().Text("Te verwerken orders").Value("3");
                })
                .HtmlAttributes(new { style = "width: 300px" })
                .ClientEvents(events => events.OnChange("OnStateComboBoxChange"))
        ))
    .Columns(column =>

3 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 09 May 2011, 03:34 PM
Hello Roel Martens,

I suspect that the error you are getting is due to the way the grid component is configured to be rendered. As you may know in order to use server templates you should use grid's Render method (and @{CODE} construct) instead of directly writing to the response (through the use of @(CODE) construct). Please refer to the razor version (clicking the View tab of the example's code viewer) of the demo in question for more details.

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
Jeroen Eikmans
Top achievements
Rank 1
answered on 09 May 2011, 03:52 PM
Thanks for the quick reply.

I got it working now, but only when i remove the code below.
When i run the app with the code for adding items i get this error : CS1593: Delegate 'System.Action' does not take 1 arguments

.Items(item =>
{
    item.Add().Text("Alle orders").Value("1");
    item.Add().Text("Afgekeurde orders").Value("2");
    item.Add().Text("Te verwerken orders").Value("3");
})

I'm pretty new to Razor so excuse me if it's a noob question :)
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 09 May 2011, 04:07 PM
Looked at the demo http://demos.telerik.com/aspnet-mvc/razor/combobox/clientsidebinding and have figured it out now.
Tags
Grid
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or