Author Topic: cell with conditional display text  (Read 300 times)

TenarisDev

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 7
    • View Profile
cell with conditional display text
« on: July 05, 2023, 09:02:06 pm »
Hi,

I'm trying to make it so that when a cell in the grid has a value "TRUE" it shows "validated" and in the case that it is different from "TRUE" , it shows "not verified"
var dataMock2 = [{"VALID_EMAIL":"TRUE"}];
 

var obj3 = {
      width: "100%",
      height: 800,
      resizable: true,
      title: "",
      showBottom: false,
      scrollModel: { autoFit: true },
      dataModel: { data: dataMock2 },
      colModel: [
        { title: "VERIFIED MAIL", dataType: "STRING", dataIndx: "VALID_EMAIL",formula: function (ui) {                       
          var rd =  ui.rowData=="TRUE"?"VALIDATED":"No VALIDATED";
          return rd;
      } }
      ]
    }

    $("#grid_json").pqGrid(obj3);


Thank you very much for the help

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: cell with conditional display text
« Reply #1 on: July 05, 2023, 11:08:46 pm »
that can be done with column.render callback.

Code: [Select]
colModel: [
        { title: "VERIFIED MAIL", dataType: "string", dataIndx: "VALID_EMAIL",
          render: function (ui) {                       
            return ui.cellData == "TRUE"?"VALIDATED":"No VALIDATED";
         }
       }
]

TenarisDev

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: cell with conditional display text
« Reply #2 on: July 06, 2023, 12:41:20 am »
Thanks, this is great!