Bruno17 / MIGX

MIGX for revo 2.2 and above
84 stars 78 forks source link

MIGX 2.13.0-rc3 this.renderChunk error #371

Open geesmo opened 3 years ago

geesmo commented 3 years ago

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 commented 3 years ago

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

Bruno17 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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