Hi,
I have to sort a column in my mvc view, on click of a small icon in the table header part ascending and descending order alternatively.
<style type="text/css">
table.sortable thead {
background-color: #eee;
color: #666666;
font-weight: bold;
cursor: default;
}
style>
<script src="http://www.kryogenix.org/code/browser/sorttable/sorttable.js" type="text/javascript">
var newTableObject = document.getElementById("myTable")
sorttable.makeSortable(newTableObject);
script>
<table id="myTable" style="width:100%" border="0" cellspacing="0" cellpadding="0" class="sortable">

suman kalyan64 reputationPosted Jun 30, 2014, 4:39 AM EDT
@{
WebGrid grid = new WebGrid(Model, null, null, 30);
}
@grid.GetHtml(tableStyle: "table table-bordered table-striped", headerStyle: "gridHead", footerStyle: "gridFooter", alternatingRowStyle: "gridAltRow",
rowStyle: "gridRow",
fillEmptyRows: true, numericLinksCount: 20,
columns: new[]
{
grid.Column(header: "S.No",format: item => item.WebGrid.Rows.IndexOf(item) + count),
grid.Column("Name","Name"),
grid.Column("District.Name","District Name"),
)
}
)
Jaima Joseph93 reputationPosted Jun 30, 2014, 8:35 PM EDT
Anupam SinghRank #643 · 3.7K reputationPosted Jun 30, 2014, 9:04 PM EDT
Set action on table header and render partial view for the same.
Jaima Joseph93 reputationPosted Jul 2, 2014, 1:30 AM EDT
vijay krishna56 reputationPosted May 11, 2017, 2:15 AM EDT
complete soruces code
Sort A Table