I am using @grid.GetHtml
gridview to show the grid in my ASP.NET MVC4 application.
Default Sort is not working while using WebGrid Helper With Column (Primary Key) as hidden.
Using SP to fetch the web grid data and also default sort is given in SP.
My code:
@grid.GetHtml(
htmlAttributes: new
{
id = "XXXX"
},
tableStyle: "table table-bordered table-condensed table-hover table-striped",
headerStyle: "info",
footerStyle: "webgrid-footer",
alternatingRowStyle: "webgrid-alternating-row",
selectedRowStyle: "webgrid-selected-row",
rowStyle: "gridrow",
columns: grid.Columns(
grid.Column("AAAA", "AAAA",style:"hidecol") //Primary Column Name is “AAAA”
)
)
JQuery Code to hide Column Header of Primary Column.
<script type="text/javascript">
$(document).ready(function() {
$("# XXXX th:nth-child(1)").hide();
});
</script>