Is there a way to set the initial starting record?

Is there a way to set the initial starting record?

iisfaqiisfaq Posts: 9Questions: 2Answers: 0
edited October 2010 in General
I would like for example to have the DataTable's first row be row 1536

I would like the user to be able to click a hyperlink on a previous page and the grid will then start from the index I tell it.

I would want the pagination to work properly as well with Ajax loading.

Cheers

Chris

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can make use of a plug-in like this to do that: http://datatables.net/plug-ins/api#fnDisplayRow . It might need to be altered slightly to make it display as he first row, rather than just on the page, but that will show the basic principle.

    Allan
  • iisfaqiisfaq Posts: 9Questions: 2Answers: 0
    Hi Allan

    Thanks for the info - but I have since found that I can simple configure an init parameter to do the work.

    $(document).ready(function () {
    $('#example').dataTable({
    "bSort": false,
    "bFilter": false,
    "bLengthChange": false,
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bServerSide": true,
    "iDisplayStart": <%=GetStartIndex()%>,
    "iDisplayLength": 29,
    "sAjaxSource": "/QuakeMap/Single/ServerProcessing.aspx",
    "fnServerData": fnDataTablesPipeline,
    "fnRowCallback": function (nRow, aData, iDisplayIndex) {
    /* Append the grade to the default row class name */
    if (iDisplayIndex == 0)
    $(nRow).addClass('row_selected');
    return nRow;
    }
    });


    Cheers

    Chris
  • iisfaqiisfaq Posts: 9Questions: 2Answers: 0
    I am using it on the quake site at http://quake.crowe.co.nz

    We have had an earthquake about 7 weeks ago in Christchurch, New Zealand.

    We have well over 2,000 afrer shocks hence the need for this great DataTables object.

    This has made the site better - The site went from 300 visitors to 4300 when a Quake hit this afternoon (4.8) and the DataTables made the site handle it better then previously.

    Chris
    http://quake.crowe.co.nz
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'd forgotten about iDisplayStart :-). Well found!

    Nice use of DataTables on your site - thanks very much for the link! Great to hear that DataTables is proving to be useful!

    Allan
This discussion has been closed.