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

[Solved] Razor syntax for server template wont render - no errors

2 Answers 48 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.
T
Top achievements
Rank 1
T asked on 20 Apr 2011, 09:47 PM
hello, i have followed the demo EXACTLY and have no errors, but when the grid renders it is empty using this:

 
@{
        Html.Telerik().Grid(Model.Products)
            .Name("StoreProductsLayout2")
            .Columns(columns =>
            {                                              
                columns.Template(
                    @<text>
                        <div>               
                            <div>
                                <button value="@{ Response.Write(item.StoreOwned ? "Added" : "Add Product"); }" class="_selectProduct" @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); } />                
                                <input type="hidden" value="@item.StoreProductId" name="spId" />
                                <input type="hidden" value="@item.StoreOwned.ToString().ToLower()" name="storeOwned" />
                            </div>
                            <div class="dvimg gl-ProductImage">
                                <img src="../../Content/images/laptop.png" alt='<#= Name #>' class='@item.ClassStoreOwned _selectProduct' @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); } /> 
                            </div>
                            <div class="gl-ProductName">
                                <a class="_selectProduct" title="<#= Name #>" @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); }>@item.Name</a>
                            </div>
                            <div class="gl-ProductPrice">
                                <p>@item.Price.ToString("C")</p>
                            </div>
                        </div>
                    </text>
                ).Title("").Width(36).HtmlAttributes(new { style = "text-align:center" });                                                                                                                     
            })
            .DataBinding(dataBinding => dataBinding.Ajax().Select("GetStoreProducts", "StoreProduct")) 
            .Pageable(x => x.Position(GridPagerPosition.Both))
            .Sortable(x => x.OrderBy(z => z.Add(y => y.Name)))
            .Scrollable()
            .ClientEvents((Action<GridClientEventsBuilder>)ViewBag.OnGridLoad)
            .EnableCustomBinding(true)
            .Render();                               
        }


When I put in client template syntax it does render that correctly. I am nesting this grid within a telerik window and as a partial view.

Why doesnt this worK???

thanks !

2 Answers, 1 is accepted

Sort by
0
T
Top achievements
Rank 1
answered on 20 Apr 2011, 10:02 PM
Ok, there was 2 relics from the other <#= #> syntax that i removed and it still doesnt work:

@{
            Html.Telerik().Grid(Model.Products)
                .Name("StoreProductsLayout2")
                .Columns(columns =>
                {
                    columns.Template(
                        @<text>
                        <div>               
                            <div>
                                <button value="@{ Response.Write(item.StoreOwned ? "Added" : "Add Product"); }" class="_selectProduct" @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); } />                
                                <input type="hidden" value="@item.StoreProductId" name="spId" />
                                <input type="hidden" value="@item.StoreOwned.ToString().ToLower()" name="storeOwned" />
                            </div>
                            <div class="dvimg gl-ProductImage">
                                <img src="../../Content/images/laptop.png" alt='@item.Name' class='@item.ClassStoreOwned _selectProduct' @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); } /> 
                            </div>
                            <div class="gl-ProductName">
                                <a class="_selectProduct" title="@item.Name" @{ Response.Write(item.StoreOwned ? "" : " onclick='productSelected'"); }>@item.Name</a>
                            </div>
                            <div class="gl-ProductPrice">
                                <p>@item.Price.ToString("C")</p>
                            </div>
                        </div>
                        </text>
                    ).Title("").Width(36).HtmlAttributes(new { style = "text-align:center" });
                })
                .DataBinding(dataBinding => dataBinding.Ajax().Select("GetStoreProducts", "StoreProduct"))   // we need to pass store id to this method; - update .rebind and the other grid that calls this as well
                .Pageable(x => x.Position(GridPagerPosition.Both))
                .Sortable(x => x.OrderBy(z => z.Add(y => y.Name)))
                .Scrollable()
                .ClientEvents((Action<GridClientEventsBuilder>)ViewBag.OnGridLoad)
                .EnableCustomBinding(true)
                .Render();                               
        }
0
T
Top achievements
Rank 1
answered on 20 Apr 2011, 11:07 PM
OK, so i figured it out - i am loading my grid using ajax so i need to use client template :(
Tags
Grid
Asked by
T
Top achievements
Rank 1
Answers by
T
Top achievements
Rank 1
Share this question
or