dynamically set max value for aLengthMenu
dynamically set max value for aLengthMenu
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]
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]
This discussion has been closed.
Replies
[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]