Author Topic: Carriage Return for multiple values in a cell  (Read 2170 times)

neoinbiz

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 22
    • View Profile
Carriage Return for multiple values in a cell
« on: September 11, 2019, 11:49:00 pm »
I have a field that has multiple values and when it returns the values it words wraps
I want carriage return for each value that is separated by "|".
Ultimately just carriage return each value minus the "|".

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Carriage Return for multiple values in a cell
« Reply #1 on: September 12, 2019, 09:24:56 am »
"|" can be replaced with "<br/>" in column.render callback

Code: [Select]
render: function(ui){
  return ui.cellData.replace(/\|/g,"<br/>");
}

neoinbiz

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Carriage Return for multiple values in a cell
« Reply #2 on: September 12, 2019, 06:34:12 pm »
Thank you for the reply

I get this error "Unable to get property 'replace' of undefined or null reference"

Code: [Select]
{ title: "Deployed Location", width: 200, dataIndx: "DeployedLocations", hidden: hideLoc, /*hideLoc uses the varible from the dropdown list deployedLoc and the condtion is around Line#312*/
filter: { type: "textbox",
        condition: 'contain',
        listeners: ['keyup']
     },
render: function(ui){
  return ui.cellData.replace(/\|/g,"<br/>");
}      
},

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Carriage Return for multiple values in a cell
« Reply #3 on: September 12, 2019, 08:41:37 pm »
It can be modified to take care of null / undefined values. Hope you have understood the concept and make changes according to the field values in your column.

Code: [Select]
render: function(ui){
  return (ui.cellData || "").replace(/\|/g,"<br/>");
}
« Last Edit: September 12, 2019, 08:44:12 pm by paramvir »