Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tried binding in juery it was successful,but not sorting  for binding and i used web service for sorting i have used plugging in js file tablesort.js


What I have tried:

i have tried binding in juery it was successful,but not sorting for binding and i used web service for sorting i have used plugging in js file tablesort.js


JavaScript
<pre> <script language="javascript" type="text/javascript">

        window.onload = function() {
            fnLoading_Start();
            var jsonData = {};
            jsonData.TRANSTYPE = "II"
            var weburl = "../../UI/ws/ws_Accounts.asmx/ACC_INV_PRINT_AUTHORISATION";
            JSON.stringify(jsonData);
            $.ajax({
                type: "POST",
                url: weburl,
                data: JSON.stringify(jsonData),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function(response) {
                    alert("Failure : " + response.d);
                },
                error: function(response) {
                    alert("Error : " + response.d);
                }
            });
            return false;
        }


        function OnSuccess(response) {
            //  alert(response.d);
            var xmldoc = $.parseXML(response.d);
            var xml = $(xmldoc);
            var InvAuth = xml.find("Table");


            //create a new row from the last row of gridview
            var row = $("[id*=dgInvoice] tr:last-child").clone(true);
            //remove the lst row created by binding the dummy row from code behind on page load
            $("[id*=dgInvoice] tr").not($("[id*=dgInvoice] tr:first-child")).remove();
            //Look for the Hidden Field and fetch the CustomerId.
            $.each(InvAuth, function() {
                var InvAuth = $(this);
                $("td", row).eq(1).html($(this).find("TRNS_TYPE").text());
                $("td", row).eq(2).html($(this).find("INV_CRTNO").text());
                $("td", row).eq(3).html($(this).find("INV_CRTDT").text());
                $("td", row).eq(4).html($(this).find("CREATEDBY").text());
                $("td", row).eq(5).html($(this).find("INV_CRT_DAT").text());
                $("td", row).eq(6).html($(this).find("CLIENTNAME").text());
                $("td", row).eq(7).html($(this).find("TOTAL_AMT").text());
                $("[id*=dgInvoice]").append(row);
                row = $("[id*=dgInvoice] tr:last-child").clone(true);
            });
             
            fnLoading_Stop();
        }
$(document).ready(function() {
        $("#dgInvoice").tablesorter();
        });
 </script>
Posted
Updated 10-Jan-17 20:18pm
v2

1 solution

You can use Jquery DataTable (DataTables | Table plug-in for jQuery[^]) to bind the data from your web service. It has got inbuilt sorting functionality.

Just need to pull the data from webservice. Then parse the data to JSON format and then initialize the jquery dataTable.
 
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