Need help with template column

5 posts, 1 answers
  1. James
    James avatar
    4 posts
    Member since:
    Oct 2012

    Posted 16 Oct 2012 Link to this post

    HI all,

    I'm a bit new to Kendo, so forgive me if this is an easy question;

    I have a grid of orders. The last column of the grid needs to be a link/button/whatever that launches a bit of JavaScript that does some AJAX stuff. Pretty simple. I found that documentation on the columns.Template method and I _think_ that's what I want. The problem is that I have only found examples where one field from the model is being used in the method call and I need three;
    columns.Template(p =>
    {@<a href="#"
    onclick="GetListOfVendorsByCountyAndProductType('@p.County', '@p.ProductTypeId.ToString()', '@p.OrderId');">Select Vendor</a>;       
     I tried the snippet above but I got an error on the page that said "CS0201: Only assignment, call, increment, decrement, await and new object expressions can be used as a statement"

    Any advice? Please remember I'm VERY new to the Kendo stuff.

  2. Answer
    Dimo avatar
    8406 posts

    Posted 19 Oct 2012 Link to this post

    Hello James,

    You can use the following syntax:


    Note that is is a server template which works with server binding. If you are using Ajax binding, you need a ClientTemplate, as explained in the Grid configuration help article.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. James
    James avatar
    4 posts
    Member since:
    Oct 2012

    Posted 19 Oct 2012 Link to this post

    Thanks Dimo, that worked!
  4. Hassan
    Hassan avatar
    10 posts
    Member since:
    Oct 2010

    Posted 09 Nov 2012 Link to this post

    I get

    CS0103: The name 'p' does not exist in the current context

    when I try the proposed solution for AJAX binding. 

            .Columns(columns => {
                columns.Bound(p => p.Id).Visible(false);
                columns.Bound(p => p.Title).Width(280);
                columns.Bound(p => p.Brand).Width(70);           
                columns.Bound(p => p.SellPrice).Width(40);
                columns.Bound(p => p.PacketWeight).Width(60);
                columns.Bound(p => p.Enabled).Width(30);   
                @Html.ActionLink("Edit", "Home", new { id = p.Id })

            .DataSource(dataSource => dataSource
            .Model(model => model.Id(p => p.Id))
            .Read(read => read.Action("GetProducts", "Product").Data("additionalData"))
            .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))





  5. Rich Coleman
    Rich Coleman avatar
    19 posts
    Member since:
    Jan 2008

    Posted 31 Jan 2013 Link to this post


    It should be

                @Html.ActionLink("Edit", "Home", new { id = item.Id })
Back to Top