Skip to content
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

MIGX 2.13.0-rc3 this.renderChunk error #371

Open
geesmo opened this issue May 14, 2021 · 5 comments
Open

MIGX 2.13.0-rc3 this.renderChunk error #371

geesmo opened this issue May 14, 2021 · 5 comments

Comments

@geesmo
Copy link

geesmo commented May 14, 2021

Summary
After updating to MIGX 2.13.0-rc3 all MIGX TVs that had in the Grid Columns "renderer":"this.renderChunk" crached.
They show all the MIGX TV value as JSON on the grid column and when editing they do not show the values and save does not work.

Step to reproduce
create a MIGX TV with a listbox-multiple TV type field and put some resources on the inputOptionValues:

[
{"caption":"Console codes", "fields":[
{"field":"console","caption":"Console","inputTVtype":"listbox-multiple","inputOptionValues":"@eval return $modx->runSnippet('listMyResources_adv',array('parent' => 15));"}
]}
]

listMyResources_adv snippet returns "pagetile:id" options for every capable resource.

on the grid Columns use renderChunk:

[
{"header": "Console", "width": "160", "sortable": "true", "dataIndex": "console" , "renderer": "this.renderChunk"}
]

Observed behavior
MIGX TV value shown as JSON on the grid column and when editing the selected values are not shown and save does not work.

Expected behavior
The grid column must show the resources pagetitles and editing and save must work.

Workaround
remove the renderer from the grid Columns and everything is working.
the only problem is that on the table now you see the "pagetitle:id" as values and not only the "pagetitle". Its a little bit annoying when you develop a backend for your customer that needs a clear view.

Environment
MODX version 2.8.2, nginx 1.18.0.2-2.centos.7+p18.0.35.0+t210402.1610 , mysql 10.2.37-1.el7.centos

@Bruno17
Copy link
Owner

Bruno17 commented May 15, 2021

did you try the same setup with MIGX 2.12 and/or MODX 2.8.1 ?

@Bruno17
Copy link
Owner

Bruno17 commented May 15, 2021

what do you have in the renderchunk - tpl and what is the code of your listMyResources_adv snippet?
Did you have created a new column for the renderChunk - column or did you use the existing console column?
You need to create another column for rendering with the renderChunk - renderer.

@geesmo
Copy link
Author

geesmo commented May 15, 2021

Hi Bruno, MIGX 2.12 and MODX 2.8.1 was working perfectly. Meaning that it was showing on the column the resource pagetitle and everything was working.

my snippet 'listMyResources_adv' code is:

$parent = $modx->getOption('parent',$scriptProperties,9);
$parentObj = $modx->getObject('modResource',$parent);
if (!($parentObj instanceof modResource)) { return ''; }
$criteria = $modx->newQuery('modResource');
$criteria->where(array(
'parent' => $parentObj->get('id'),
));
$criteria->sortby('pagetitle','ASC');
$resArray = $parentObj->getMany('Children',$criteria);
$resources = array();
foreach($resArray as $res) {
if ($res instanceof modResource) {
$resources[] = $res->get('pagetitle') . '==' .$res->get('pagetitle').':'.$res->get('id');
}
}
$out = implode("||",$resources);
return $out;

I dont understand what you mean by 'what do you have in the renderchunk - tpl'?

@Bruno17
Copy link
Owner

Bruno17 commented May 15, 2021

when you use the renderChunk - renderer for a column, you need to put something into the renderChunk template field.

It seems you are confusing renderChunk with renderFirst - renderer?
I think, the renderFirst - renderer would do, what you want.

@dimitrihilverda
Copy link

Is your snippet static? if so, that's the problem, somehow in the newer modx versions this can not be a static file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants