title: Jquery datatable pagination
body: <p>In the below code ,the html loads up and will call group_map set python function.My question is that there is pagination enabled in the system so if a user in page 3 deletes a entry the page reloads and brings back to page 1.How to make the user stay  on the same page after deleting an entry</p>
  
  <p>Datatable used is from <a href="http://www.datatables.net/" rel="nofollow noreferrer">http://www.datatables.net/</a></p>
  
  <pre><code>                 &lt;html&gt;
                   &lt;head&gt;
                   &lt;link rel="stylesheet" type="text/css" href="css/datatable.css" /&gt;
                   &lt;script type="text/javascript" src="js/jquery.dataTables.js"&gt;&lt;/script&gt;
                   &lt;/head&gt;
                   &lt;script&gt;
                   var oTable;
  
                   function fnFormatDetails ( nTr )
                   {
                      var iIndex = oTable.fnGetPosition( nTr ) ;
                      var aData = oTable.fnSettings().aoData[iIndex]._aData;
  
                      var sOut = aData[6];
  
                      return sOut;
                   }
  
                    $(document).ready(function() {
                    $.ajaxSetup({ cache: false });
                      oTable = $('#s_group_table').dataTable( {
                         "aoColumns": [
                            {"sWidth": "30%" },
                            {"sWidth": "20%" },
                            {"bSortable": false,"sWidth": "5%" },
                            {"bSortable": false,"sWidth": "5%" },
                         ],
                         "aaSorting": [[0, 'desc']],
                         "bProcessing": true,
                         "bServerSide": true,
                         "sAjaxSource": "/repo/group_set/",
                         "bJQueryUI": true,
                         "sPaginationType": "full_numbers",
                         "bFilter": false,
                         "oLanguage" : { "sZeroRecords": "No data found", "sProcessing" : "Fetching Data" }
                      });
  
                   });
  
  
                   function delete_set(id)
                   {
                         $.post("/repo/group_set_delete/" + id) ;
                         oTable.fnDraw(true) ;
                         location.reload();
                   }
                   &lt;/script&gt;
  
                   &lt;div id="s_group_table"&gt;
                   &lt;table cellpadding="0" cellspacing="0" border="0"  width="100%"&gt;
                      &lt;thead&gt;
                         &lt;tr&gt;
                            &lt;th width="30%"&gt;Name&lt;/th&gt;
                            &lt;th width="30%"&gt;&lt;/th&gt;
                         &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                         &lt;tr&gt;
                            &lt;td colspan="2" class="dataTables_empty"&gt;No data found&lt;/td&gt;
                         &lt;/tr&gt;
                      &lt;/tbody&gt;
                   &lt;/table&gt;
                   &lt;/div&gt;
  
  
  
  
  
    def group_set(request):
       try:
          response_dict = {}
          offset = int(request.GET.get('iDisplayStart'))
          limit = int(request.GET.get('iDisplayLength')) + offset
          echo = request.GET.get('sEcho')
  
          sort_cols = int(request.GET.get('iSortingCols'))
          for i in range(0, sort_cols):
             dir = request.GET.get('iSortDir_' + str(i))
             if dir == "asc":
                dir = ""
             else:
                dir = "-"
             order_by = dir + group_map (request.GET.get('iSortCol_' + str(i))) + ","
  
          order_by = order_by.strip(',')
  
  
          total =  GroupSet.objects.filter(pk=request.profile.my_id).count()
          if limit &gt; total:
             limit = total
  
          if order_by == "":
             groupset = GroupSet.objects.filter(pk=request.profile.my_id)[offset:limit]
          else:
             groupset = GroupSet.objects.filter(pk=request.profile.my_id).order_by(order_by)[offset:limit]
  
          p_array = []
          p_array_o = []
          for q in studentprofilegroup_map:
             delete_l = "&lt;a&gt;&lt;img title='Delete group' class=center src=\"/repo/images//del.gif\" onclick=javascript:delete_set(\"%d\")&gt;&lt;/a&gt;&amp;nbsp;" % (q.id)
  
             emp_name = q.first_name + q.last_name
  
             p_array_o = [emp_name , delete_l ]
             p_array.append(p_array_o)
          response_dict.update({'sEcho': echo, 'iTotalRecords': total, 'iTotalDisplayRecords': total, 'aaData': p_array}) ;
  
          return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
       except:
          print "No records found"
  </code></pre>
  
  <p>Delete function is as</p>
  
  <pre><code>   def group_set_delete(request,gid):
      try:
        s_gp = GroupSet.objects.filter(pk=gid)
        s_gp.delete()
      except:
        print "could not be deleted"
  </code></pre>