ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on September 11, 2017, 01:46:46 pm

Title: Render function
Post by: queensgambit9 on September 11, 2017, 01:46:46 pm
I would like to add an image if cellData contains certain criteria. Currently I use the render function which works fine (used in colModel).
When applying to all cells...what would be the best approach thinking of speed etc?

Would it be possible to add html attributes etc already in the datamodel (using json data)?
Title: Re: Render function
Post by: paramvir on September 11, 2017, 04:43:03 pm
It's fine to do it with render, it doesn't affect the speed in most of the cases, unless there is inefficient code written inside render.

postRender can also be used.

Adding html entities inside json data is not good from security point of view.
Title: Re: Render function
Post by: queensgambit9 on September 11, 2017, 06:28:49 pm
Thanks, any suggestions how I should parse all cell data (all columns and rows) in an efficient way with render?

Title: Re: Render function
Post by: paramvir on September 11, 2017, 07:42:24 pm
You don't need to parse through all rows and columns to get cell value which is readily available as ui.cellData

Writing efficient code in render function boils down to writing efficient javascript code:

1. caching object properties,

2. avoiding loops,

3. use grid instance to call pqgrid methods.

https://paramquery.com/pro/tutorial#topic-methods
Title: Re: Render function
Post by: queensgambit9 on September 11, 2017, 07:53:05 pm
Thanks. Not sure how to execute it once for all data...currently I use render in the colmodel... how can I trigger for all columns?
Title: Re: Render function
Post by: paramvir on September 11, 2017, 07:58:15 pm
columnTemplate can be used to define render for all columns.

https://paramquery.com/pro/api#option-columnTemplate
Title: Re: Render function
Post by: queensgambit9 on September 11, 2017, 09:12:15 pm
Great, thanks.