in Onclient Load event of the xpage or custom control(better)
if(screen.width>1024){
var temp="#{javascript:sessionScope.noOfRows='20'}";
}
else{
var temp="#{javascript:sessionScope.noOfRows='40'}"
}
I did not check this code. Please verify before use in production