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">
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
vijay krishnaPosted May 11, 2017, 6:15 AM
complete soruces code
Sort A Table
Jaima JosephPosted Jul 2, 2014, 5:30 AM
Anupam SinghPosted Jul 1, 2014, 1:04 AM
Set action on table header and render partial view for the same.
Jaima JosephPosted Jul 1, 2014, 12:35 AM
suman kalyanPosted Jun 30, 2014, 8:39 AM
@{
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"),
)
}
)