-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specific renderer (currently only supported for jqGrid) not being rendered #95
Comments
This function currently only works with jqgrid... I use is also with functions: $colTypeIcon->setRendererParameter('formatter', 'currencyFmatter ', 'jqGrid'); I extra escape it, because i use common formatter functions: jQuery.extend($.fn.fmatter , {
currencyFmatter : function(cellvalue, options, rowdata) {
return "$"+cellvalue;
}
});
jQuery.extend($.fn.fmatter.currencyFmatter , {
unformat : function(cellvalue, options) {
return cellvalue.replace("$","");
}
}); |
Can u try it with build in function, custom functions (with extend) and normal custom functions without the escape (see link above) Then we can change it. |
I will be back next week and then try it. Thanks so far! |
I started testing. Using the build in function works fine: $col->setRendererParameter('formatter', "function (value, options, rowObject) { return '<b><u>' + value + '</u></b>'; }");
// or
$col->setRendererParameter('formatter', "function (value, options, rowObject) { return '<b><u>' + value + '</u></b>'; }", 'jqGrid');
// dito
$col->setRendererParameter('formatter', 'function (value, options, rowObject) { return "<b><u>" + value + "</u></b>"; }');
// or
$col->setRendererParameter('formatter', 'function (value, options, rowObject) { return "<b><u>" + value + "</u></b>"; }', 'jqGrid'); custom functions are next. |
I tried: $col->setRendererParameter('formatter', 'formatNumber', 'jqGrid');
#$col->setRendererParameter('formatter', "formatNumber", 'jqGrid');
#$col->setRendererParameter('formatter', 'formatNumber');
#$col->setRendererParameter('formatter', "formatNumber"); The JS generated is always: {name: "c_number",index: "c_number",label: "Number",width: "5",hidden: false,sortable: true,search: true,formatter: "formatNumber"}, I added each formatter functions standalone using inline and / or headScript: var formatNumber = function (value, options, rowObject) {
console.log('formatNumber1');
return '<b><u>' + value + '</u></b>';
}
jQuery.extend($.fn.fmatter , {
formatNumber : function(cellvalue, options, rowdata) {
console.log('formatNumber2');
return "$"+cellvalue;
}
}); Unfortunately their is no formatting and nothing logged into console. |
I commented out the escape line in https://github.com/ThaDafinser/ZfcDatagrid/blob/master/src/ZfcDatagrid/Renderer/JqGrid/View/Helper/Columns.php#L150-L153: } elseif ($key == 'formatter') {
if (stripos($value, 'formatter') === false && stripos($value, 'function') === false) {
#$value = '"' . $value . '"';
} The JS must not be placed via inline script but headscript! The formatter is now called successfully! But you have to use the non-extend code: var formatNumber = function (value, options, rowObject) {
console.log('formatNumber1');
return '<b><u>' + value + '</u></b>';
} Otherwise you get an error: |
This issue was moved to zfc-datagrid/zfc-datagrid#7 |
In my controller I set this rendererParameter:
But it seems like the code is not generated inside the view as long as I don't remove the third parameter 'jqgrid'.
BTW: Is there a recommended way to escape the javascript?
I would recommend to put the javascript functions into the view and simply parse a string as second parameter so that jqgrid can use it to callback my view function.
Unfortunately parsing a string to the second parameter will cause the code to generate a string in double quotes:
But to make jqgrid use it as a callback the quotes need to be removed:
The text was updated successfully, but these errors were encountered: