Dynamic scrolling
Dynamic scrolling
yogesh1001
Posts: 7Questions: 0Answers: 0
Hi ,
I want scroll bar to beenabled after 5 rows i.e. after 175px. (as per my code). This is done .But when i want to display just 2 rows ,the height should be "auto" not 175px as fixed . I tried with below code .I got the auto height for row count less than 5 .But when row count is greate 5 still m getting the same height i.e auto. Scroll bar is not enabling .Scroll bar shd be enabled after 175px or 5 rows. So please any one can resolve this issue ?
code :
-------
var oTable1=[]
for(var i=1 ; i <= 4; i++)
{
var scrollLength="auto";
oTable1[i-1]=$("#dataTable_"+i).dataTable({
"bInfo" : false,
"bSort" : false,
"bFilter" : false,
"bProcessing" : false,
"bPaginate" : false,
"bAutoWidth": false,
"sScrollY" : scrollLength,
});
var rowCount= oTable1[i-1].fnGetData().length;
if (rowCount > 5) {
scrollLength = "175px";
oTable1[i-1].fnSettings().oScroll.sY="175px";
}
$("#dataTable_"+i).dataTable({
oTable1[i-1].fnDraw();
});
}
I used loop because i m iterating a loop in my jsp and same table will be displayed for 4 times with different content.
I want scroll bar to beenabled after 5 rows i.e. after 175px. (as per my code). This is done .But when i want to display just 2 rows ,the height should be "auto" not 175px as fixed . I tried with below code .I got the auto height for row count less than 5 .But when row count is greate 5 still m getting the same height i.e auto. Scroll bar is not enabling .Scroll bar shd be enabled after 175px or 5 rows. So please any one can resolve this issue ?
code :
-------
var oTable1=[]
for(var i=1 ; i <= 4; i++)
{
var scrollLength="auto";
oTable1[i-1]=$("#dataTable_"+i).dataTable({
"bInfo" : false,
"bSort" : false,
"bFilter" : false,
"bProcessing" : false,
"bPaginate" : false,
"bAutoWidth": false,
"sScrollY" : scrollLength,
});
var rowCount= oTable1[i-1].fnGetData().length;
if (rowCount > 5) {
scrollLength = "175px";
oTable1[i-1].fnSettings().oScroll.sY="175px";
}
$("#dataTable_"+i).dataTable({
oTable1[i-1].fnDraw();
});
}
I used loop because i m iterating a loop in my jsp and same table will be displayed for 4 times with different content.
This discussion has been closed.
Replies