Page 1 of 1

How i hide grid value?

Posted: Thu Feb 23, 2017 8:03 am
by imtiaz123
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?

Re: How i hide grid value?

Posted: Thu Feb 23, 2017 9:05 am
by mishika
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

Re: How i hide grid value?

Posted: Thu Feb 23, 2017 3:43 pm
by amosbatto
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.

Re: How i hide grid value?

Posted: Thu Feb 23, 2017 3:56 pm
by amosbatto
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.

Re: How i hide grid value?

Posted: Sun Feb 26, 2017 2:13 am
by blackbird
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.

Re: How i hide grid value?

Posted: Wed Apr 12, 2017 2:26 am
by adijadhav
Dear blackbird ,
To hide a grid row use the following code it works fine.
Code: Select all
$("#grid_id").getControl(row_number,column_number).hide();