I have inserted the link buttons "Add New Record" and "Save All" at the bottom of my Webgrid. But I want them to be in the footer of the WebGrid
. I have searched for this a lot, but found nothing. Can someone tell me how to add a link or button in the "footer" of a WebGrid
.
Here is some code of my 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="spanEmpId_@(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="spanEmpName_@(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="spanEmpDesg_@(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="Edit_@(item.EmpId)" class="edit">Edit</a>
<a href="#" id="Update_@(item.EmpId)" style="display:none" class="update">Update</a>
<a href="#" id="Cancel_@(item.EmpId)" style="display:none" class="cancel">Cancel</a>
<a href="#" id="Save_@(item.EmpId)" style="display:none" class="save">Update</a>
<a href="#" id="iCancel_@(item.EmpId)" style="display:none" class="icancel">Cancel</a>
<a href="#" id="Delete_@(item.EmpId)" class="delete">Delete</a>
</text>)
))
WebGrid doesn't have a modifiable footer per se. However if you view the tutorial on ASP.NET you'll see a way to make that happen in css.
What you can do is make your last row the same css class as your footer, or you can insert your buttons/links with javascript. Neither approach is clean, but as far as I can tell there is not a better way to accomplish your goal without rewriting the control. Many people have suggested looking into Telerik's controls, if you have/can get a license for their stuff.