Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By imtiaz123
#789346
How i hide grid value?
I have a grid. i want to hide this grid.
i tried this code but don't work.

$(document).ready ( function()
{
var gridLength = $("#gridVar001").getNumberRows();
var uid = $("#currentUser").getText();
var matchfound = false;
var gridval = $("#gridVar001").getValue();
//form[gridVar001][2][cxodd01]
$("#gridVar001").find("select").each ( function()
{
if($(this).attr('id').indexOf('cxodd') > 0)
{
alert("$(this).val() = " + $(this).val() + "; uid=" + uid);
if ($(this).val() == uid)
{
$(this).parent().parent().parent().parent().parent().show();
}
else if ($(this).val() != uid)
{
//alert('hiding');
$(this).parent().parent().parent().parent().parent().hide();
}
}
else
{
//alert("ddid="+$(this).attr('id'));
}
}
)
//}
//)

//( function() {

$("#checkJanuary").css("display", "none");
$("#CheckFebruary").css("display", "none");

if(($("#checkJanuary").getValue()==1) || ($("#checkJanuary").getValue()=='["1"]') || ($("#checkJanuary").getValue()=="1"))
{
$("gridVar002").hide();
//$("#cxodd02").hide();
//$("#datetime0000000001").hide();
//$("#dropdown0000000002").hide();
//$("#textarea0000000001").hide();
//$("#commentCOFebruary").hide();
}

else if(($("#CheckFebruary").getValue()==1) || ($("#CheckFebruary").getValue()=='["1"]') || ($("#CheckFebruary").getValue()=="1"))
{
$("#gridVar001").hide();
//$("#cxodd01").hide();
//$("#datetime0000000001").hide();
//$("#dropdown0000000002").hide();
//$("#textarea0000000001").hide();
//$("#commentCCOJanuary").hide();
}
}
)
;

how can i solve this?
By mishika
#789348
Hello,

In order to hide a grid, use the following:
Code: Select all
$("#grid-id").hide();
In order to hide a column of a grid, use:
Code: Select all
$("#grid-id").hideColumn(colIndex);
In order to access the value of a particular row and column in a grid, use:
Code: Select all
$("#grid-id").getValue(row,column);
Your code is syntactically incorrect. So please refer to the following link to have more information regarding the use of javascript in grids:
http://wiki.processmaker.com/3.0/Grid_C ... t_in_Grids

Best Regards,
Mishika
User avatar
By amosbatto
#789359
It helps if you space your code correctly so it is readable:
Code: Select all
$(document).ready( function() {
   var gridLength = $("#gridVar001").getNumberRows();
   var uid = $("#currentUser").getText();
   var matchfound = false;
   var gridval = $("#gridVar001").getValue();
   //form[gridVar001][2][cxodd01]
   $("#gridVar001").find("select").each( function() {
      if ($(this).attr('id').indexOf('cxodd') > 0) {
         alert("$(this).val() = " + $(this).val() + "; uid=" + uid);
         if ($(this).val() == uid) {
            $(this).parent().parent().parent().parent().parent().show();
         }
         else if ($(this).val() != uid) {
            //alert('hiding');
            $(this).parent().parent().parent().parent().parent().hide();
         }
      }
      else {
         //alert("ddid="+$(this).attr('id'));                                                                            
      }
   })

   //}
   //)
   //( function() {
						
   $("#checkJanuary").css("display", "none");
   $("#CheckFebruary").css("display", "none");
  
   if (($("#checkJanuary").getValue()==1) || ($("#checkJanuary").getValue()=='["1"]') || 
         ($("#checkJanuary").getValue()=="1")) {
      $("gridVar002").hide();
      //$("#cxodd02").hide();
      //$("#datetime0000000001").hide();
      //$("#dropdown0000000002").hide();
      //$("#textarea0000000001").hide();
      //$("#commentCOFebruary").hide();
   }
   else if(($("#CheckFebruary").getValue()==1) || ($("#CheckFebruary").getValue()=='["1"]') || 
      ($("#CheckFebruary").getValue()=="1")) {
      $("#gridVar001").hide();
      //$("#cxodd01").hide();
      //$("#datetime0000000001").hide();
      //$("#dropdown0000000002").hide();
      //$("#textarea0000000001").hide();
      //$("#commentCCOJanuary").hide();
   }
});
I have no idea what you did wrong, but $("gridVar002").hide() and $("#gridVar001").hide() should hide the grids. You probably mispelled the ID of a field or tried to reference something that doesn't exist, so the Javascipt code stopped. You need to use the debugger in your web browser when loading the DynaForm to figure it out. Comment out parts of your code until you figure out where your error is located.
User avatar
By amosbatto
#789360
If your question is how to hide a field inside a grid, then you can hide it this way:
Code: Select all
$("[id='form[clientsList][1][name]']").hide()
Where "clientsList" is the ID of the grid, 1 is the row number and "name" is the ID of the field in the grid. Numbering of rows in grids starts from 1.
By blackbird
#789391
It's also my question but little different.

I have logged in user. I want to show just the logged in user and want to hide the others. How to hide a row of a grid using for loop?

I know it's a wrong code but I want a solution like this.
Code: Select all
$(document).ready ( function()
{
              var gridLength = $("#gridJan").getNumberRows();
              var uid = $("#currentUser").getText();
              var matchfound = false;
              var gridval = $("#gridJan").getValue();


              for(var i = 1; i<=gridLength; i++)
              {
                 // I am testing with all user's in the DropDown list of a grid.
                  var DropDownUser = $("#gridJan").find("cxodd01").val();
                  if(DropDownUser == uid)
                  {
                      $(this).parent().parent().parent().parent().parent().show();
                  }
                  else
                  {
                      $(this).parent().parent().parent().parent().parent().hide();
                  }
              }
                          //form[gridVar001][2][cxodd01]
                           
});

Thanks.

As you have got seen that after every single updat[…]

issue with processmaker 3.2

Hello! The solution to your question is the foll[…]

BPMN project disappeared

Hi Alex! , maybe you forgot to save your process[…]

mcrypt extension is deprecated!

Hello Ehsan! If you did not find the mcrypt ext[…]