Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Below is my jquery code to implement search filter for gridview along with paging,i am able to implement searching but the problem is in paging if i click edit button i am getting back to first page of my gridview instead of staying in that particular page.How to get stayed in that particular page on clicking edit button in gridview 


<script>
            $(function () {
                // Setup - add a text input to each footer cell
                $('#<%=GridView1.ClientID %> th').each(function () {
                    var title = $(this).text();
                    if (title == "Audio Name" || title == "Physician  Name" || title == "Speciality") {
                        $(this).html(title + '<br/><input type="text" style="width:120px" placeholder="Search ' + title + '" />');
                    }
                    else {
                        if (title != " ") {
                            //$(this).html(title + '<br/><input type="text" style="background-color:#646464;border:none" disabled="disabled"   />');
                        }
                    }
                });

                // DataTable
                //var table = $('#<%=GridView1.ClientID %>').DataTable({
                var table = $('#<%=GridView1.ClientID %>').prepend($('<thead></thead>').append($('#<%=GridView1.ClientID %>').find('tr:first'))).DataTable({
                    "paging": true,
                    "ordering": false,
                    "info": false,
                    "pageLength": 10,
                    "bLengthChange": false
                });

                table.columns().every(function () {
                    var that = this;

                    $('input', this.header()).on('keyup change', function () {
                        if (that.search() !== this.value) {
                            that
                                .search(this.value)
                                .draw();
                        }
                    });
                });
            });

    </script>


What I have tried:

I tried by taking bsavestate=true as shown below
<pre>// DataTable
                //var table = $('#<%=GridView1.ClientID %>').DataTable({
                var table = $('#<%=GridView1.ClientID %>').prepend($('<thead></thead>').append($('#<%=GridView1.ClientID %>').find('tr:first'))).DataTable({
                    "paging": true,
                    "ordering": false,
                    "info": false,
                    "pageLength": 10,
                     "bsavestate"=true,
                    "bLengthChange": false
                });

By doing in this way i am able to stay in the same page on clicking edit button in gridview which solves my problem but again if i am running the application or again if i am again getting logged in i am seeing that page where i was before running the application instead of seeing first page of gridview
Posted
Comments
F-ES Sitecore 16-Jan-17 4:10am    
It might help if you said what plug-in you are using for the tables.
kav@94 16-Jan-17 4:50am    
kav@94 16-Jan-17 4:50am    
jquery.dataTables.min.js and jquery-1.11.1.min.js

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