Returning to correct page from a sub form using datatable javascript & AJAX

Returning to correct page from a sub form using datatable javascript & AJAX

RickZlerRickZler Posts: 5Questions: 1Answers: 0

Hi thanks for help in advance. I have a ASP.NET MVC App. using data tables with javascript & AJAX. I have a purchase order history datatable that uses pagination to page through many hundreds of purchase orders. On the purchase order history page I have a linked to each transaction with detail information about that specific transaction. So say I have 1000 transactions on 20 pages of pagination. Now say I browse to page 19 of 20 and click on the details button to view the purchase order details. When I click the back to purchase order submission page instead of taking me back to page 19 of 20 it always takes me back to page number one. I know this has something to do with the index page variable but not sure how to fix it. THANKS so much for any advice. Here is the link that takes to back to the main history page in bootstrap.

' ' '

<

div class="btn-group btn-group-lg">
<a class="btn btn-default" href="@Url.Action("ViewHistory")">
<i class="fa fa-arrow-left"></i>
<span class="sr-only">Index</span>
</a>
' ' '

And here is the viewhistory cshtml page

' ' ' {
ViewBag.Title = "Purchase Order History";
}

@Html.Partial("_datatables")

Purchase Order History

Ref. No. Client PO Num Status
$(document).ready(function() { $('#myTable').dataTable({ "bServerSide": true, "sAjaxSource": "AjaxHandler", "bProcessing": true, "order": [[0, "desc"]], "aoColumnDefs": [ { "aTargets": [4], "mRender": function (data, type, row) { return '
' + '' + 'Details' + '' + '' + 'Download' + ''; } } ] }); });

' ' '

Answers

  • RickZlerRickZler Posts: 5Questions: 1Answers: 0
          <
    div class="btn-group btn-group-lg">
    <a class="btn btn-default" href="@Url.Action("ViewHistory")">
    <i class="fa fa-arrow-left"></i>
    <span class="sr-only">Index</span>
    </a>
    
  • RickZlerRickZler Posts: 5Questions: 1Answers: 0
    <
    div class="btn-group btn-group-lg">
    <a class="btn btn-default" href="@Url.Action("ViewHistory")">
    <i class="fa fa-arrow-left"></i>
    <span class="sr-only">Index</span>
    </a>
    ' ' '
    And here is the viewhistory cshtml page
    ' ' ' {
    ViewBag.Title = "Purchase Order History";
    }
    @Html.Partial("_datatables")
    Purchase Order History 
    Ref. No.
    Client
    PO Num
    Status
    
    
    $(document).ready(function() { $('#myTable').dataTable({ "bServerSide": true, "sAjaxSource": "AjaxHandler", "bProcessing": true, "order": [[0, "desc"]], "aoColumnDefs": [ { "aTargets": [4], "mRender": function (data, type, row) { return '
    ' + '' + 'Details' + '' + '' + 'Download' + ''; } } ] }); }); 
    
    
  • RickZlerRickZler Posts: 5Questions: 1Answers: 0

    Sorry couldn't figure out editing my original post so I did it on comments section

  • RickZlerRickZler Posts: 5Questions: 1Answers: 0

    I also asked this over at S.O. but explained the problem in much more detail

    stackoverflow.com/questions/40705959/javascript-ajax-always-defaulting-to-page-1-in-a-pagination-list-when-going-ba

This discussion has been closed.