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

[Solved] Template column rendered before table

7 Answers 98 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.
Andrés
Top achievements
Rank 1
Andrés asked on 29 Jun 2011, 06:49 PM
Hi, I'm using this code:

@Html.Telerik.Grid(Model).
    Name("matches").
    Columns(Sub(cols)
              With cols
                .Bound(Function(o) o.Player1)
                .Template(Sub(o)
                            @<text>
                              <img
                              alt="@o.LocalTeamName"
                              src="@Url.Content("~/Content/TeamLogos/" &  o.LocalTeamName & ".png")" />
                            </text>
                          End Sub).Title("Logo")
              End With
            End Sub)

The end result is that the images are rendered *before* the table and the column that's supposed to render those images is empty. That column has a correct heading, but the content for template columns seems to run before the actual rendering of the grid.

This looks just like the sample in the demo page but there must be something off. What am I doing wrong?

Thanks
Andrés

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 30 Jun 2011, 08:18 AM
Hello Andrés,

 This is not the proper way to declare a razor template. Please check the razor template example for a working demo (check the view tab of the code viewer). Here is the relevant code:

@{ Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Template(
                @<text>
                    <img
                        alt="@item.CustomerID "
                        src="@Url.Content("~/Content/Grid/Customers/" + item.CustomerID + ".jpg") "
                      />
                </text>
            ).Title("Picture");


Regards,
Atanas Korchev
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
Andrés
Top achievements
Rank 1
answered on 30 Jun 2011, 01:33 PM
Hi Atanas,
Thanks for your reply. But I'm not using C#,  It's VB.
Unfortunately, your demo site doesn't have any visual basic samples, but so far I managed to make everything work in vb except for this.

Cheers,
Andrés
0
Atanas Korchev
Telerik team
answered on 01 Jul 2011, 06:28 AM
Hello Andrés,

 I believe the VB code for setting the template in Razor is the same. Did you try it?

All the best,
Atanas Korchev
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
Andrés
Top achievements
Rank 1
answered on 01 Jul 2011, 01:20 PM
Hi Atanas,
Yes I tried it.
In vb, you must type the "sub(item)" part because otherwise you get an "expression expected" compiler error.

Thanks,
Andrés
0
Atanas Korchev
Telerik team
answered on 01 Jul 2011, 01:31 PM
Hi Andrés,

 In that case you can try rendering the grid inside a razor block - call its Render method:

@Code
 
   Html.Telerik().Grid().Render()
 
End Code


Kind regards,
Atanas Korchev
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
Andrés
Top achievements
Rank 1
answered on 01 Jul 2011, 01:37 PM
Amazing... that DID work. Does it mean that I always have to use this in vb to get the grid to render correctly?
Should I file a bug or something?

Thanks
0
Atanas Korchev
Telerik team
answered on 04 Jul 2011, 08:23 AM
Hi Andrés,

This seems to be a limitation of the Razor support for VB.NET. I tried the following with the built-in WebGrid helper:

@Code
    ViewData("Title") = "Home Page"


    Dim grid As New WebGrid(New String() {"One", "Two"})
End Code


@grid.GetHtml(alternatingRowStyle:="alt",columns:=grid.Columns(
                grid.Column("Foo",format:= Function(item)@<text>$@item</text> End Function)))


The result was exactly the same. I also found the following pages discussing the same issue:
http://stackoverflow.com/questions/5136270/razor-inline-template-item-keyword-in-vb
http://forums.asp.net/t/1657902.aspx/2/10?Razor+Inline+Template+Item+Keyword+in+VB

Regards,
Atanas Korchev
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
Tags
Grid
Asked by
Andrés
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Andrés
Top achievements
Rank 1
Share this question
or