issue with asyncTable and javascript, how to hide a row

Hello,

The issue is :

I have an asyncTable with result, I want to add a checkbox below my table, if the user check the checkbox causes the display of a specific rows of the table and mask others.
I used the following javascript code below contains function hideRows() to hide the rows in the asyncTable following a condition, but it did not work :frowning:


function hideRows(){

 // get the table rows
var arrayRows = document.getElementById("#{caf:cid('defaultForm:asyncTable')}").rows; 

// we apply the length property
var length = arrayRows.length; 

// we set the variable i in the loop
for (var i=0; i<length-1; i++) {
	// get cells of the current row
	var arrayColls = arrayRows[i].cells;

		// get cells values
		var var1= arrayColls[0].innerHTML;
		var var2 = arrayColls[1].innerHTML;
		var var3 = arrayColls[2].innerHTML;

		// if difference between cells of the current row
		if(var1 != var2 || var2 != var3 || var1 != var3) {
			// hide the current row
			arrayRows[i].style.display = "none";
		} 
	}
}

I also used: arrayRows[i].style.display = β€œβ€; but doesn’t work
But if i use another treatment like change the row color, it works fine, for exp : arrayRows[i].style.backgroundColor = β€œ#EE7600”;

please help me if you have any idea

thanks & regards,

any suggestion please ??

What browser are you using to test this?

I tried something like this in firefox and it seemed to work.

function hideRows() {
  var tableModel = CAF.model("#{caf:cid('defaultForm:asyncTable')}");
  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[0].innerHTML;
    var var2 = arrayColls[1].innerHTML;
    var var3 = arrayColls[2].innerHTML;

    // if difference between cells of the current row
    if(var1 != var2 || var2 != var3 || var1 != var3) {
      // hide the current row
      row.style.display = "none";
    }
  }
} 
1 Like

Thank you very much Eric, it works very well :slight_smile:

Please i have another little question related to my asyncTable, i created the topic below :

http://tech.forums.softwareag.com/techjforum/posts/list/0/51707.page#185064

Regards