Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By sinanb
#7008
Hi,
Does anyone know a way to limit the row number for a grid? Normally, users may enter as many rows as they wish, but what if they are expected to enter no more than 5 rows for instance? How can we accomplish that requirement?
I tried, controlling the maximum rows in a javascript function, which I assigned to grid's onaddrow event. But it was no success, because the function fires after the row has been added.
Any clues?
Regards.
By sinanb
#7013
Problem solved. I've controlled the maximum number of lines in a function. After this maximum number has been reached, overwriting the addGridRow function of the grid with another function does the job.
Below is a sample code.
Code: Select all
function gridMaxRowsAlert(){
	alert("You've reached the maximum number of lines for this grid.");

}

function onAddNewRow(){
	var MAXROWS=8;
	var totalRows = Number_Rows_Grid("ItemList", "Amount");
	if (totalRows>=MAXROWS){
		getObject("ItemList").addGridRow=gridMaxRowsAlert;
		return false;
	}
	return true;
}

grid_ItemList.onaddrow=onAddNewRow;
By adijadhav
#787161
sinanb wrote:Problem solved. I've controlled the maximum number of lines in a function. After this maximum number has been reached, overwriting the addGridRow function of the grid with another function does the job.
Below is a sample code.
Code: Select all
function gridMaxRowsAlert(){
	alert("You've reached the maximum number of lines for this grid.");

}

function onAddNewRow(){
	var MAXROWS=8;
	var totalRows = Number_Rows_Grid("ItemList", "Amount");
	if (totalRows>=MAXROWS){
		getObject("ItemList").addGridRow=gridMaxRowsAlert;
		return false;
	}
	return true;
}

grid_ItemList.onaddrow=onAddNewRow;


Is it possible for you to explain the variable used in this above code. even code.
By adijadhav
#787162
Hi,
Use the above code for limiting the grid rows.
Where we get number of rows from grid using getNumberRows.
Code: Select all
$('#grid_variable').onAddRow(function(){
	var MAXIMUMROWS=10;
	var  countOfRows=$('#grid_variable').getNumberRows();

               if(countOfRows>MAXIMUMROWS)
              {
	                  alert("You have reached the maximum lines");
                           $('#grid_variable').deleteRow();
                }
	});
By adijadhav
#787324
sinanb wrote:Hi,
Does anyone know a way to limit the row number for a grid? Normally, users may enter as many rows as they wish, but what if they are expected to enter no more than 5 rows for instance? How can we accomplish that requirement?
I tried, controlling the maximum rows in a javascript function, which I assigned to grid's onaddrow event. But it was no success, because the function fires after the row has been added.
Any clues?
Regards.

Do you want a quick way to delete passwords from P[…]

Try the CloudMigration PST Converter to convert […]

In the rapidly evolving world of online sports be[…]

STEPN integrates social networking and games that […]