2013-10-22 76 views
0

我正在嘗試獲取在此代碼中工作的操作鏈接。害怕我是一個絕對的新手,所以需要幫助拼命。 鏈接只需調用一個鏈接到UnderwriterID的小管理窗口,這將是UserName。如何將ActionLink插入Kendo網格?

@(Html.Kendo().Grid<QMS.ViewModels.UnderwriterVM>() 
       .Name("Grid1") 
       .Columns(columns => 
       { 
        columns.Bound(p => p.PortfolioID).Width(100); 
        columns.Bound(p => p.UnderwriterID).Width(100); 
        columns.Bound(p => p.UWName).Width(100); 
        columns.Bound(p => p.UWLastName).Width(100); 
        columns.Bound(p => p.PremiumAuthority).Width(100); 
        columns.Bound(p => p.DiscountAuthority).Width(100); 
        columns.Bound(p => p.UW_ShortID).Width(100); 
        columns.Bound(p => p.MaxDiscount).Width(100); 
        columns.Template(p => @Html.ActionLink("Manage", "ManageUW", new { pfid = ViewBag.PF, uwid = Model.FirstOrDefault().UserName })); 
        columns.Command(command => { command.Destroy(); }).Width(110); 
       }) 
       .ToolBar(toolbar => 
        { 
       toolbar.Create(); 
       toolbar.Save();   
        }) 
         //.Pageable() 
       .Sortable() 
       .Scrollable(scr => scr.Height(430)) 
       .Filterable() 
       .Editable(editable => editable.Mode(GridEditMode.InCell)) 
       .DataSource(dataSource => dataSource 
        .Ajax() 
        .Batch(true) 
        .ServerOperation(false) 
        .Create("Underwriters_Create", "Grid") 
        .Update("Underwriters_Update", "Grid") 
        .Destroy("Underwriters_Destroy", "Grid") 
        .Read("Read_Underwriters", "Grid", new { vPortId = ViewBag.PF}) 
        .Model(model => 
           { 
            model.Id(p => p.UnderwriterID); 
            model.Field(p => p.PortfolioID).DefaultValue(ViewBag.PF); 
            model.Field(p => p.UWName).Editable(true); 
            model.Field(p => p.UWLastName).Editable(true); 
            model.Field(p => p.PremiumAuthority).Editable(true); 
            model.Field(p => p.DiscountAuthority).Editable(true); 
           })) 
       ) 
+0

使用模板是實現此目的的方法。你可以顯示你的結果HTML。 – unicorn2

回答

0

這裏是我的專欄客戶端模板的樣子:

columns 
    .Bound(p => p.UserName) 
    .Title("") 
    .Filterable(false) 
    .Sortable(false) 
    .Width(103) 
    .ClientTemplate(Html.ActionLink("<span class=\"k-icon k-i-pencil\"></span>Manage", "ManageUW", "YourController", new { pfid = ViewBag.PF, uwid = "#=UserName#" }, new { @class = "k-button k-button-icontext" }).ToHtmlString()); 
+0

這裏有另一種格式:.ClientTemplate(「Manage」); – AggieEngineer2k

-1

嘗試是這樣的

VB代碼

.ClientTemplate(Html.ActionLink("Roles", "UserRolesManage", New With {.UserId = "#=UserId#", .UserLogin = "#=UserLogin#"}).ToHtmlString() 

C#代碼:

.ClientTemplate(@Html.ActionLink("Roles", "UserRolesManage", New {UserId = "#=UserId#", UserLogin = "#=UserLogin#"}).ToHtmlString() 
+0

Downvoter你能告訴我爲什麼嗎? –