This is a migrated thread and some comments may be shown as answers.
Grid ToolBar Template compilation error - CS1525: Invalid expression term ')'
4 Answers 67 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ozzy Knox
Top achievements
Rank 1
Ozzy Knox asked on 18 Nov 2010, 11:03 AM
I am trying to use the new Custom ToolBar Template functionality that was released in Q3 2010, but I have run into an issue which I am not able to solve.  I am using the syntax that I have pulled from the Custom ToolBar demo for the Grid.

A snippet of my view code is as follows:

<%= Html.Telerik().Grid<Vigilaris.Booking.Services.ScheduledCourseDTO>()
       .Name("ScheduledCoursesGrid")
                   .ToolBar(tb => tb.Template(() => { %>
                         <label>Course:</label>
                           <% Html.Telerik().ComboBox().Name("Courses").Render(); %>
                         <% }))
  ...
%>

When I run the application, I get the following error: 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1525: Invalid expression term ')'

Source Error:

Line 7:      <%= Html.Telerik().Grid<Vigilaris.Booking.Services.ScheduledCourseDTO>()
Line 8:          .Name("ScheduledCoursesGrid")
Line 9:                      .ToolBar(tb => tb.Template(() => { %>
Line 10:                           <label>Course:</label>
Line 11:                             <% Html.Telerik().ComboBox().Name("Courses").Render(); %>

I have checked and confirmed that I am used the Telerik.Web.Mvc.dll for MVC 2 from Q3 2010. It seems to me that it is not picking up this new functionality for some reason.

4 Answers, 1 is accepted

Sort by
0
Ozzy Knox
Top achievements
Rank 1
answered on 18 Nov 2010, 11:22 AM
Okay, I managed to find the solution. It seems that when using this approach with the custom toolbar template, the rendering is achieved slightly differently and this is not highlighted or made very obvious in the demos, although it is there if you look carefully. Below is the corrected syntax for my example which now works together with an explanation to follow:

<% Html.Telerik().Grid<Vigilaris.Booking.Services.ScheduledCourseDTO>()
    .Name("ScheduledCoursesGrid")
    .ToolBar(tb => tb.Template(() => { %>
            <label>Course:</label>
            <% Html.Telerik().ComboBox().Name("Courses").Render(); %>
            <% }))
    .DataKeys(keys => keys.Add(sc => sc.Id))
    .DataBinding(dataBinding =>
        dataBinding.Ajax()
            .Select("_List", "ScheduledCourse", new { id = (int)ViewData["id"] })
            .Update("_UpdateAjax", "ScheduledCourse")
            .Delete("_DeleteAjax", "ScheduledCourse")
    )
    .Columns(columns =>
    {
        columns.Bound(c => c.Id).Width(20);
        columns.Bound(c => c.ScheduledDateTime).Width(120);
        columns.Bound(c => c.Location).Width(150);
        columns.Command(commands =>
        {
            commands.Edit().ButtonType(GridButtonType.Image);
            commands.Delete().ButtonType(GridButtonType.Image);
        }).Width(180).Title("Commands");
    })
    .Editable(editing => editing.Mode(GridEditMode.PopUp))
    .Sortable()
    .Footer(true)
    .Render();
%>

Note the following which is bolded in the code snippet:
  1. I have removed the equal sign "=" from the opening <% 
  2. I have had to add a call to the Render() method at the end

And that's it. I hope somebody else gets benefit from my experience.
0
Erik
Top achievements
Rank 1
answered on 18 Nov 2010, 04:44 PM
Brilliant Ozzy thanks a bunch!

I had the same error when trying to use a template for a column. This solved it. Keen eye :)
0
Lyle
Top achievements
Rank 1
answered on 03 Dec 2010, 08:15 AM
Bug, google, your post, thanks!
0
Rene
Top achievements
Rank 1
answered on 07 Dec 2010, 04:08 PM
You totally Rock!  Been at this problem for 3 days now.
Tags
Grid
Asked by
Ozzy Knox
Top achievements
Rank 1
Answers by
Ozzy Knox
Top achievements
Rank 1
Erik
Top achievements
Rank 1
Lyle
Top achievements
Rank 1
Rene
Top achievements
Rank 1
Share this question
or