I have a a gridpanel that has the following fields:
Name ID Address Home_Phone Cell
Some records that return to the store may not have any data for some of these fields, rather then display an empty column for that record in the grid I would like to show a default value of N/A.
So I would have
Name ID Address Home_Phone Cell
Shaun 2 My Address N/A N/A
Rather then:
Name ID Address Home_Phone Cell
Shaun 2 My Address
I know of two ways to do this:
- In the back end if the field doesn’t exists return a “N/A” for that column in the JSON.
- Create a template with a method that check if the record doesn’t contain the value return “N/A”.
My question is, is there an easier way to tell the grid column if no value is found in the record display the default N/A?
You can add a renderer for your columns. You either add a renderer for each column or you can define your own column if you have more columns with this behaviour.
//add this for each column config (works for null values and empty strings)
or add the renderer to a component that extends the column and use that throughout the application.
It’s easier to do this on the front end rather then modifying the backend and sent extra unnecessary data like ‘N\A’.
Hope It helps.