Page 1 of 1

reduce the rows on a subform

Posted: Tue Apr 12, 2011 4:49 pm
by johan
Is there a way to reduce the number of rows that you can enter on a subform ?
Limit seems no solution.
This limits the number of rows displayed but not the number of rows that can be entered.

Thanks

Johan

Re: reduce the rows on a subform

Posted: Wed Apr 13, 2011 1:59 am
by admin
Johan,

There is no default settings that can be changed on a subform to do what you have asked, however..

If you put this code in the JavaScript textarea of the form that holds the subform, you can restrict it to whatever you want.

you will need to change these 2 parameters in nuLoadThis()

limitRows(pSubformName, pMaximumRows);

Code: Select all


function nuLoadThis() {
	limitRows(pSubformName, pMaximumRows);
}


function limitRows(pSubformName, pMaximumRows){

   var fldPrefix = Array();
   fldPrefix[0]  = '';
   fldPrefix[1]  = 'code';            //-- lookup code field
   fldPrefix[2]  = 'description';     //-- lookup description field
   fldPrefix[3]  = 'luup_';           //-- lookup button
   fldPrefix[4]  = 'cal_';            //-- calander button

   var rowPrefix = Array();
   var rowPrefix = nuSubformRowArray(pSubformName);

   var totalCols = document.getElementById('columns' + pSubformName).value;
   for(var r = pMaximumRows ; r < rowPrefix.length ; r++){
      for(var c = 0 ; c < totalCols ; c++){

         var fieldName = document.getElementById(pSubformName + c).value;

         for(var p = 0 ; p < fldPrefix.length ; p++){
            if(document.getElementById(fldPrefix[p] + rowPrefix[r] + fieldName)){
               document.getElementById(fldPrefix[p] + rowPrefix[r] + fieldName).style.visibility = 'hidden';
            }
         }
      }
   }

}




Steven

Re: reduce the rows on a subform

Posted: Wed Apr 13, 2011 8:09 pm
by johan
Steven,

This works fine, thanks a lot.

Only the delete button stays visible.

I've tried to add fldPrefix[5] = 'delete'; //-- delete button but that's not correct.

Can you help me on that?

Thanks;
Johan

Re: reduce the rows on a subform

Posted: Thu Apr 14, 2011 3:26 am
by admin
Here you go..

Code: Select all



function limitRows(pSubformName, pMaximumRows){

   var fldPrefix = Array();
   fldPrefix[0]  = '';
   fldPrefix[1]  = 'code';            //-- lookup code field
   fldPrefix[2]  = 'description';     //-- lookup description field
   fldPrefix[3]  = 'luup_';           //-- lookup button
   fldPrefix[4]  = 'cal_';            //-- calander button
   fldPrefix[5]  = 'row';             //-- tickbox button

   var rowPrefix = Array();
   var rowPrefix = nuSubformRowArray(pSubformName);

   var totalCols = document.getElementById('columns' + pSubformName).value;
   for(var r = pMaximumRows ; r < rowPrefix.length ; r++){
      for(var c = 0 ; c < totalCols ; c++){

         var fieldName = document.getElementById(pSubformName + c).value;
//document.getElementById(rowPrefix[r] + fieldName).style.visibility

         for(var p = 0 ; p < fldPrefix.length ; p++){
            if(document.getElementById(fldPrefix[p] + rowPrefix[r])){
               document.getElementById(fldPrefix[p] + rowPrefix[r]).style.visibility = 'hidden';
            }
            if(document.getElementById(fldPrefix[p] + rowPrefix[r] + fieldName)){
               document.getElementById(fldPrefix[p] + rowPrefix[r] + fieldName).style.visibility = 'hidden';
            }
         }
      }
   }

}


Re: reduce the rows on a subform

Posted: Thu Apr 14, 2011 6:46 am
by johan
works perfect,

thanks
johan