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 bayatloo

I write a trigger before dynaform that calls data from an excel file and fill the grid control. one of the columns in this grid control is textbox and the value of that is: 0,1,2 or 3.
I want to show the value of this column in an other field (in grid control) by red circles as bellow:
Untitled.png (5.66 KiB) Viewed 1668 times
I make 3 link controls in grid control for circle images.
when the value of column in a row is 1, so the link control related to " one red circle" image should be visible and other images ("tow red circles" and "three red circles" )should be hidden.
how can i set this by a trigger before dynaform?
By bayatloo
amosbatto wrote: Mon Aug 05, 2019 6:45 pm I created a programming example for you: ... grid_field
i tried to use this code for more than one column (as the picture), but it's not work correctly; would you please correct this.
Untitled.png (9.13 KiB) Viewed 1638 times

Code: Select all
//set to the ID fo the grid:
var gridId = "test_image_grid";
//set to the ID of the "rating" grid field with the number of images to display:
var ratingFieldIdG = 'rating'; 
var ratingFieldIdY = 'rating2'; 
var ratingFieldIdR = 'rating3'; 
//set to the column number of the "rating" field in the grid:
var ratingColNoG = 3; 
var ratingColNoY = 4; 
var ratingColNoR = 5; 
//set to the ID of the grid field where the images will be displayed:
var placeholderFieldIdG = 'placeholder';
var placeholderFieldIdY = 'placeholder2';
var placeholderFieldIdR = 'placeholder3';

var formId = $("form").prop("id");
var reRatingChangedG = new RegExp("^\\["+gridId+"\\]\\[(\\d)\\]\\["+ratingFieldIdG+"\\]");
var reRatingChangedY = new RegExp("^\\["+gridId+"\\]\\[(\\d)\\]\\["+ratingFieldIdY+"\\]");
var reRatingChangedR = new RegExp("^\\["+gridId+"\\]\\[(\\d)\\]\\["+ratingFieldIdR+"\\]");

$("#" + formId).setOnchange( function(fieldIdG,fieldIdY,fieldIdR, rating,rating2,rating3, oldRating) {
  var aMatchG = fieldIdG.match(reRatingChangedG);
  var aMatchY = fieldIdY.match(reRatingChangedY);
  var aMatchR = fieldIdR.match(reRatingChangedR);
  if (aMatchG) {
    var rowNo = aMatchG[1];
    var imagesHtml = "";
    rating = parseInt(rating);
    rating = isNaN(rating) ? 0 : rating;
    for (i=0; i < rating; i++) {
    	imagesHtml += ' <img src="../../../../images/select-icon.png">';
    $("#"+gridId+"_"+rowNo+"_"+placeholderFieldIdG).html( imagesHtml );
  if (aMatchY) {
    var rowNo = aMatchY[1];
    var imagesHtml = "";
    rating2 = parseInt(rating2);
    rating2 = isNaN(rating2) ? 0 : rating2;
    for (i=0; i < rating2; i++) {
    	imagesHtml += ' <img src="../../../../images/select-icon.png">';
    $("#"+gridId+"_"+rowNo+"_"+placeholderFieldIdY).html( imagesHtml );
   if (aMatchR) {
    var rowNo = aMatchR[1];
    var imagesHtml = "";
    rating3 = parseInt(rating3);
    rating3 = isNaN(rating3) ? 0 : rating3;
    for (i=0; i < rating3; i++) {
    	imagesHtml += ' <img src="../../../../images/select-icon.png">';
    $("#"+gridId+"_"+rowNo+"_"+placeholderFieldIdR).html( imagesHtml );

//hide all the placeholder fields with the Dynaform loads:
var grdRows = $("#"+gridId).getNumberRows();

for (var i = 1; i <= grdRows; i++) {
	var oPlaceholderFieldG = $("#form\\["+gridId+"\\]\\["+i+"\\]\\["+placeholderFieldIdG+"\\]");
	var imagesHtml = "";
	var rating = parseInt( $("#"+gridId).getValue(i, ratingColNoG) );
	rating = isNaN(rating) ? 0 : rating;
  if (rating) {
    for (var i=0; i < rating; i++) {
  	  imagesHtml += ' <img src="../../../../images/select-icon.png">';
	oPlaceholderFieldG.parent().append('<span id="'+gridId+'_'+i+'_'+placeholderFieldIdG+'">'+imagesHtml+'</span>');

//hide the placeholder field when new rows are added to the grid:
$("#"+gridId).onAddRow( function(aNewRow, oGrid, rowIndex) {
  var oPlaceholderField = $("#form\\["+gridId+"\\]\\["+rowIndex+"\\]\\["+placeholderFieldIdG+"\\]");
  oPlaceholderFieldG.parent().append('<span id="'+gridId+'_'+rowIndex+'_'+placeholderFieldIdG+'"></span>');
  var oPlaceholderField = $("#form\\["+gridId+"\\]\\["+rowIndex+"\\]\\["+placeholderFieldIdY+"\\]");
  oPlaceholderFieldY.parent().append('<span id="'+gridId+'_'+rowIndex+'_'+placeholderFieldIdY+'"></span>');
  var oPlaceholderField = $("#form\\["+gridId+"\\]\\["+rowIndex+"\\]\\["+placeholderFieldIdR+"\\]");
  oPlaceholderFieldR.parent().append('<span id="'+gridId+'_'+rowIndex+'_'+placeholderFieldIdR+'"></span>');

Hello everyone Is possible to edit the code of th[…]

Buenos días a todos, de antemano gracias po[…]

Hi, Please set the display_errors = Off in your […]

Change Finger Signature Ink Color

I was wondering if it is possible to change the in[…]