Show/Hide asyncTable rows

Hello,

in my page load, the asynctable show all the rows (different & similar), this is my code in the script block controle


function deltaVersions(){
	var tableModel = CAF.model("#{caf:cid('defaultForm:asyncTable')}");  
	// get model rows list
	var rowModels = tableModel.list();    
	for (var i=0; i < rowModels.length; i++) {
		var rowModel = rowModels[i];  		 
		
		//get html element for the row  
		var row = rowModel.element;  	  
		
		// get cells of the current row  
		var arrayColls = row.cells;  	
		
		// get cells values  
		var var1 = arrayColls[1].innerHTML;
		var var2 = arrayColls[2].innerHTML;
		
		// if  difference between cells of the current row  
		if (var1 != var2 ) {
			// change the row color
			row.style.backgroundColor = "#EE7600";  
			
		}  else {
			// get the model for the row
			var rowModel = CAF.model(row);
			
			// calculate the id of the control inside the row
			var inputId = rowModel.getControlId("txtComment");
			
			// get the model for the input control
			var inputModel = CAF.model(inputId);    
    	
			// calculate the id of the control inside the row 
			var buttonId = rowModel.getControlId("btnSave");    
    	
			// get the model for the input control
			var buttonModel = CAF.model(buttonId);    
    
			// disable them
			inputModel.setDisabled(true);    
			buttonModel.setDisabled(true); 			
		}		
	}	
}
	// page loading
	window.onload=deltaVersions;

I use a group-buton radio to filter rows (show different rows and hide similar rows), I use 2 options :
On : to show only difference and hide similar
Off : to show all rows (different + similar)

The code I use for the CLICK event of option “On” is :


// get radio-button group model
var radioGroupModel = CAF.model("#{caf:cid('htmlSelectOneRadio')}");   
// get choices index   
var itemOnIdx = radioGroupModel.indexOf('optOn');  
var itemOffIdx = radioGroupModel.indexOf('optOff');  

var tableModel = CAF.model("#{caf:cid('defaultForm:asyncTable')}");  
// get model rows list
var rowModels = tableModel.list();    

// if on is checked  - show only difference
if (radioGroupModel.isSelected(itemOnIdx))  {    

	for (var i=0; i < rowModels.length; i++) {	
		var rowModel = rowModels[i];  		
		
		//get html element for the row  
		var row = rowModel.element;  	  
		
		// get cells of the current row  
		var arrayColls = row.cells;  	  
		
		// get cells values  
		var var1 = arrayColls[1].innerHTML;
		var var2 = arrayColls[2].innerHTML;
	  
		// if no difference between cells of the current row  
		if (var1 == var2) {  
			// hide the current row  
			row.style.display = 'none';  
			row.style.visibility='hidden';
		}  
	}       
}  

In the same CLICK event, I use another condition for the “Off” option,
in this other option I call the same script code in loading to show all rows, but it does not work :frowning: below the code


// if off is checked - show all   
if (radioGroupModel.isSelected(itemOffIdx)) {
 
	for (var i=0; i < rowModels.length; i++) {
		var rowModel = rowModels[i];  		 
		
		//get html element for the row  
		var row = rowModel.element;  	  
		
		// get cells of the current row  
		var arrayColls = row.cells;  	
		
		// get cells values  
		var var1 = arrayColls[1].innerHTML;
		var var2 = arrayColls[2].innerHTML;
		
		// if  difference between cells of the current row  
		if (var1 != var2) {
			// change the row color
			row.style.backgroundColor = "#EE7600";  
			
		}  else {
			// get the model for the row
			var rowModel = CAF.model(row);
			
			// calculate the id of the control inside the row
			var inputId = rowModel.getControlId("txtComment");
			
			// get the model for the input control
			var inputModel = CAF.model(inputId);    
    	
			// calculate the id of the control inside the row 
			var buttonId = rowModel.getControlId("btnSave");    
    	
			// get the model for the input control
			var buttonModel = CAF.model(buttonId);    
    
			// disable them
			inputModel.setDisabled(true);    
			buttonModel.setDisabled(true); 			
		}		
	}	
}	

The issue is about the second option “Off”, nothing happened
any suggestion ??

Thanks

problem resolved, thanks :slight_smile: