2013-01-24 37 views
1

我在Webgrid的底部插入了鏈接按鈕「添加新記錄」和「全部保存」。但我希望它們位於WebGrid的頁腳中。我已經搜尋了很多,但什麼都沒找到。有人可以告訴我如何在WebGrid的「頁腳」中添加鏈接或按鈕。在WebGrid的頁腳中添加鏈接按鈕Mvc3

這裏是我的WebGrid

@model IEnumerable<MvcGrid2.Models.Employee> 
@{ 
    WebGrid grid = new WebGrid(
    source: Model, 
    rowsPerPage: 4); 

} 

@grid.GetHtml(htmlAttributes: new { id = "WebGrid1" }, 
     tableStyle:"gridTable", 
     headerStyle: "gridHead", 
     footerStyle: "gridFooter", 
     rowStyle: "gridRow", 
     alternatingRowStyle: "gridAltRow", 
     mode: WebGridPagerModes.All, 
     firstText: "<<", 
     previousText: "<", 
     nextText: ">", 
     lastText: ">>", 
     columns: grid.Columns(  
           @* grid.Column(columnName : "EmployeeId", 
              format: @<text>@item.EmpId</text>),*@ 

           grid.Column(columnName: "Employee Id", 
              format: @<span> 
                 <span id="[email protected](item.EmpId)">@item.EmpId</span> 
                 @Html.TextBox("EmpId_" + (int)item.EmpId, (int)item.EmpId, new { @style = "display:none" }) 
                </span>), 

           grid.Column(columnName: "Employee Name", 
              format: @<span> 
                 <span id="[email protected](item.EmpId)">@item.EmpName</span> 
                 @Html.TextBox("EmpName_" + (int)item.EmpId, (string)item.EmpName, new { @style = "display:none" }) 
                </span>), 

           grid.Column(columnName: "Designation", 
              format: @<span> 
                 <span id="[email protected](item.EmpId)" >@item.Designation</span> 
                 @Html.TextBox("EmpDesg_" + (int)item.EmpId, (string)item.Designation, new { @style = "display:none" }) 
                </span>), 

           grid.Column(columnName: "Action", 
              format: @<text>      
                 <a href="#" id="[email protected](item.EmpId)" class="edit">Edit</a> 
                 <a href="#" id="[email protected](item.EmpId)" style="display:none" class="update">Update</a> 
                 <a href="#" id="[email protected](item.EmpId)" style="display:none" class="cancel">Cancel</a> 
                 <a href="#" id="[email protected](item.EmpId)" style="display:none" class="save">Update</a> 
                 <a href="#" id="[email protected](item.EmpId)" style="display:none" class="icancel">Cancel</a> 
                 <a href="#" id="[email protected](item.EmpId)" class="delete">Delete</a> 
                </text>) 


          )) 

回答

1

的WebGrid的一些代碼沒有修改頁腳本身。但是,如果您查看tutorial on ASP.NET,您會看到一種在css中發生這種情況的方法。

你可以做的是讓你的最後一行與你的頁腳相同的CSS類,或者你可以用JavaScript插入你的按鈕/鏈接。這兩種方法都不是乾淨的,但據我所知,沒有更好的方法來實現您的目標而不重寫控件。許多人建議查看Telerik的控件,如果你有/可以獲得他們的東西的許可證。

+0

Webgrid有頁腳,我已經閱讀了該教程。在這裏,沒有什麼可以在頁腳中添加控件。 –

+0

澄清我的答案有點給你。 – Billdr