ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mewbie on January 19, 2018, 09:19:01 am
-
Hello,
I have data only receiving 1 and 0, and I want to display it as ✓ and ✗ instead.
I can try with
var tickRender = function (ui) {
dataRow = ui.rowData.Circuit
// validation function
}
colModel: { title: "Circuit", width: 120, dataIndx: "Circuit", render: tickRender }
but if I have several columns it would be tedious to write every function per column,
could you help me know the proper way doing it?
Thanks
-
Any common property for all columns can be added in columnTemplate.
https://paramquery.com/pro/api#option-columnTemplate
-
Thank you,
it works great, although the function is called multiple times with column number.
-
the function is called multiple times with column number.
Not sure what you mean by that.
-
This is my function for columnTemplate :
var renderTick = function (ui) {
var dataRow = ui.rowData;
// var indxRow = ui.rowIndx;
console.log(ui);
Object.keys(dataRow).forEach(function (key) {
if (dataRow[key] == '1') {
return dataRow[key] = '✓';
} else if (dataRow[key] == '0') {
return dataRow[key] = '✗';
}
});
}
ui is called multiple times upon children tab expansion (it has several column),
not like what I thought it would be single ui call, not a problem at the moment and I don't know how to refactor it yet.
-
You have least control on how many times render is called, but your render callback is implemented incorrectly, it should return rendered value for current cell.
var renderTick = function (ui) {
if (ui.cellData == '1') {
return '✓';
} else if (ui.cellData == '0') {
return '✗';
}
});
}