ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: nuno.nogueira on February 06, 2014, 06:26:33 pm
-
The last column of my table is a calculated field (the difference between the two previous columns).
When users add a row:
- Is it possible to calculate this field automatically, disallowing users to edit?
- Can I give this column a different style (eg: color)?
-
1) If it's for view purpose only, then you can use column.render callback to calculate the field. And keep column.editable to false to disallow editing.
http://paramquery.com/pro/api#option-column-render
http://paramquery.com/pro/api#option-column-editable
2) use column.cls
http://paramquery.com/pro/api#option-column-cls
-
(I've attached the question, since it isn't being posted correclty here)
This is the definition of the column:
[code]colModel: [
{ title: "Desvio", width: 100, dataType: "float", align: "right", dataIndx: "desvio", cls:'coluna_calc', editable: false, render:function(ui){return "
-
Please refer to this live example ( css tab) for adding cls in the column.
http://paramquery.com/pro/demos/selection_checkbox
render : function(ui){
return (ui.rowData["revenue"] - ui.rowData["expenses"]);
}
-
The calculation is working OK after refreshing the table, but I was trying to have the calculation ready whenever any of the numbers in the columns were updated. I guess I need an event for cell change AND a callback function for that.
As for adding the class to the column, no matter what I do, it doens't get added. This is what I have in colModel:
{ title: "Desvio", width: 100, dataType: "float", align: "right", dataIndx: "desvio", cls:'coluna_calc', editable: false}
-
Use cellSave event to call refreshCell for the computed cell.
http://paramquery.com/pro/api#event-cellSave
http://paramquery.com/pro/api#method-refreshCell
Did you check whether class is injected in the column using DOM inspector.
EDIT:
============================================================
I see that class has been added in the column. You have to make change in css for it to take effect.
.pq-grid .coluna_calc {
color: red;
}
-
Yes, class has been added, thanks! :D
I'm now checking cellSave and refreshCell
-
(Here's the question in attahcment)
Hi,
I have to get back to the calculated column issue, sorry..
The question is, how do I trigger the function to calculate column "desvio", whenever cells in columns "atual" or "orcamento" are saved locally?
I assume the cellSave event has to included in these two columns, but how do I call the function?
This is what I have in colModel:
colModel: [
{ title: "Or
-
just call refreshCell ( {dataIndx :'desvio', rowIndx:ui.rowIndx}) or refreshRow( {rowIndx: ui.rowIndx}) from cellSave event.
-
Yes, calculated field in on, thanks!
:)