Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

reduce the rows on a subform

Post Reply
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

reduce the rows on a subform

Unread post 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
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: reduce the rows on a subform

Unread post 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
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: reduce the rows on a subform

Unread post 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
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: reduce the rows on a subform

Unread post 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';
            }
         }
      }
   }

}

johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: reduce the rows on a subform

Unread post by johan »

works perfect,

thanks
johan
Post Reply