Un foro de discusión para nuestra comunidad de hispano hablante
By josue1990
#790048
Buenas tardes a todos, necesito hacer lo siguiente:

Tengo tres grids (grid1, grid2, grid3) con cuatro filas cada uno. En cada uno de los grids tengo un dropdown llamado "producto" con 30 códigos donde el usuario puede seleccionar uno. Lo que deseo hacer es que cuando el usuario seleccione más de dos veces un mismo producto, en el mismo grid o en los otros dos, dé un mensaje de error.

Alguna idea para hacer esto? De antemano mil gracias por su ayuda!
By mishika
#790140
Hello,

To achieve the requirement you can add the following javascript in your Dynaform.

Javascript does the following:
When you add a row and select a product, you get the value of the selected product and check if it has already been selected for other rows. If it does, count the number of times it has already been selected and if this count exceeds 2 an error message is displayed and the cell is surrounded by a red border. If not, simply add the value to an array that holds the record of the selected values ​​and sets the value of the column of that grid.

Here is the javascript code:
Code: Select all
  var pdt = new Array();
function deleteList(gridID) {
  var oGrid = $("#"+gridID); 
  var iRow = oGrid.getNumberRows();
  for (; iRow > 0; iRow--) {
     oGrid.deleteRow(iRow);
  }
}
function savepdt()
{
  	var count = 0;
 	var p = this.value;
  	var exists = jQuery.inArray( p, pdt );
  	if(exists == -1){
 		pdt.push(p);
    	$(this).css("border", "");
  	}
  	else{
      var l = pdt.length;
      for(var i=0;i<l;i++){
        if(pdt[i]==p){
          count++;
        }
      }
      if(count >1){
          alert("This product has already been selected twice. Please select another product");
          $(this).css("border", "3px solid red");
      }
      else{
          pdt.push(p);
          $(this).css("border", "");
      }
    }
}
$("#gridVar001").onAddRow( function(aRow, oGrid, rowNumber) {
   $("#form\\[gridVar001\\]\\[" + rowNumber + "\\]\\[product\\]").change(savepdt);
} );
$("#gridVar002").onAddRow( function(aRow, oGrid, rowNumber) {
   $("#form\\[gridVar002\\]\\[" + rowNumber + "\\]\\[product1\\]").change(savepdt);
} );
$("#gridVar003").onAddRow( function(aRow, oGrid, rowNumber) {
   $("#form\\[gridVar003\\]\\[" + rowNumber + "\\]\\[product2\\]").change(savepdt);
} );
deleteList("gridVar001");
deleteList("gridVar002");
deleteList("gridVar003");
Hope this helps

Best Regards
Mishika

Fildena double 200 mg capacity to move the relaxin[…]

Wat is Fildena Double 200?

Fildena double 200 mg capacity to move the relaxin[…]

💥 Join the Exclusive Trading Community and Experie[…]

Briefly introduce the topic and provide context. S[…]