dynamically set max value for aLengthMenu

dynamically set max value for aLengthMenu

tihg7947tihg7947 Posts: 9Questions: 0Answers: 0
edited August 2013 in General
Hello,

Is there a way to dynamically set the max value of aLengthMenu to be the maximum number of records in the request? I was thinking it might be as simple as using iTotalRecords for the value but it is coming up undefined. I'm pretty new to software development and if this is blatant then I'm willing to take my licks to learn. Here is an example:

[code]

$(document).ready(function () {
$('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ServerSide.asp<%=ProgramString %>",
"aLengthMenu": [[10, 25, 50,100, <%=iTotalRecords %>], [10, 25, 50,100, <%=iTotalRecords %>]],
"sDom": 'T<"clear">flrti',
"oTableTools": {
"sSwfPath": "../copy_cvs_xls_pdf.swf"
}
} );
});


[/code]

where iTotalRecords is from ServerSide.asp:

[code]
'here we create the SQL query using "strWhere" and "strOrderBy"
SQL = "SELECT * FROM ajax " & strWhere & strOrderBy
Set rs = Session("objConn").Execute(SQL)
iTotalRecords = rs(0)
[/code]

Replies

  • tihg7947tihg7947 Posts: 9Questions: 0Answers: 0
    edited August 2013
    I got it working. I just saved it as a session variable in ServerSide.

    [code]

    var iTotalRecords = '<%=Session("iTotalRecords") %>';
    $(document).ready(function () {
    $('#example').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "ServerSide.asp<%=ProgramString %>",
    "aLengthMenu": [[10, 25, 50,100, iTotalRecords], [10, 25, 50,100, iTotalRecords]],
    "sDom": 'T<"clear">flrti',
    "oTableTools": {
    "sSwfPath": "../copy_cvs_xls_pdf.swf"
    }
    } );
    });


    [/code]

    [code]
    'here we create the SQL query using "strWhere" and "strOrderBy"
    SQL = "SELECT * FROM ajax " & strWhere & strOrderBy
    Set rs = Session("objConn").Execute(SQL)
    iTotalRecords = rs(0)
    Session("iTotalRecords") = rs2(0)
    [/code]
This discussion has been closed.