Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends I tried to implement gridview column sorting at client side using jQuery. But its not working properly. So please help me
Posted
Comments
Garth J Lancaster 27-Mar-15 22:42pm    
ok .. "But its not working properly...." - you havnt posted any code, or told us what 'not working properly' means. We cant see your screen from out here on the internet - so you have to show us what code is 'not working properly' and describe what's happening vs what should be happening. Please modify your question and try to give us a bit more to go on, else no-one here can really help you (+5 for saying please though)

1 solution

Example

ASP.NET
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
        </asp:gridview>


Jquery
JavaScript
$(document).ready(function () {
        $("th").click(function () {
            var columnIndex = $(this).index();
            var tdArray = $(this).closest("table").find("tr td:nth-child(" + (columnIndex + 1) + ")");
            tdArray.sort(function (p, n) {
                var pData = $(p).text();
                var nData = $(n).text();
                return pData < nData ? -1 : 1;
            });
            tdArray.each(function () {
                var row = $(this).parent();
                $("#GridView1").append(row);
            });
        });
    })


Refer:- sort gridview columns in client side in asp.net using jquery
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900