ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: RedBully on April 04, 2014, 01:47:14 am

Title: change cell styling programmatically
Post by: RedBully on April 04, 2014, 01:47:14 am
When a cell renders I want to change the styling of the cell based on some business rules. I see there is a property ''pq_cellcls" that is exposed declaratively. I imagine I can override this programmatically in JS by am unsure how?

VRfGPf_Pageobj.colModel = [
   { title: 'Label', editable: function (ui) { return oa.IsCellEditable(ui); },
render: function (ui) { return oa.RenderCell(ui); },
width: 200, dataType: 'text', validations: [
 {type: 'minLen', value: '1', msg: 'Label is mandatory'}
 ] }, ...

JS snippet:

    oa.RenderCell = function (ui) {

        var r = ui.rowIndx;
        var c = ui.column.dataIndx;

//how do I change the styling of the cell here?

Thanks.


Title: Re: change cell styling programmatically
Post by: paramvir on April 04, 2014, 01:48:07 pm
cell styles can be set using pq_cellcls only before rendering phase.

If it has to be set within cell render callback (i.e. during rendering phase), then you have to use addClass API and within setTimeout so that the cell style take place immediately after render phase.

Addition (10/03/2014)

cell styles can be set with pq_cellcls in column.render callback for the current cell since version 2.1.0 as shown in this demo

http://paramquery.com/pro/demos/render_cells
Title: Re: change cell styling programmatically
Post by: dbadmin on October 03, 2014, 08:13:11 pm
So which event should be used to change a style of a cell, to make sure it gets updated after loading new data, page change, sorting, etc.?
I'd like to highlight rows that have same data in a specific column (by dataIndx).
Title: Re: change cell styling programmatically
Post by: paramvir on October 03, 2014, 08:21:56 pm
It could be done in load event.

http://paramquery.com/pro/api#event-load
Title: Re: change cell styling programmatically
Post by: dbadmin on October 03, 2014, 08:27:12 pm
I was under impression that local sorting does not trigger load event. Is it not the case?
Title: Re: change cell styling programmatically
Post by: paramvir on October 03, 2014, 08:37:46 pm
sorting does not trigger load event; it triggers sort event.

But sorting doesn't modify the data, it only changes the order of the rows, so it won't affect your logic to highlight the rows /cells.

Similar is the case with paging.

Assuming your data would be static ( in the sense it won't be inline edited or pasted or new rows added, etc ) once you load your data from remote server, you only need to listen to load event.