We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    then you can try:

    ,"renderchunktpl":"[[$[[+MIGX_formname]]]]"


      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 10555
      • 32 Posts
      I have tried all solutions you suggested and the most I can get as output is a path of an image... its not rendering any of the chunk. Is there anything else I could possibly try.
        • 40981
        • 8 Posts
        Hey guys,

        Perhaps you tried Jim's suggestion here:

        http://forums.modx.com/thread/80338/migx---new-feature-renderchunk?page=3#dis-post-485280

        But then found out that jQuery wasn't defined within the manager. I'm not sure how he's using jQuery in the manager, and I don't think that jQuery selector would even work in this case based on the DOM that I see, but I translated his jQuery to barely-passable Extjs for a one-column Grid:

        $renderer['this.renderSnippet'] = "
        	renderSnippet : function(val, md, rec, row, col, s) {
        		var column = this.getColumnModel().getColumnAt(col);
        		MODx.Ajax.request({
        			url: MODx.config.base_url+'core/components/migx/processors/mgr/migx/customrenderers.php'
        			,params: {
        				type : 'snippet', 
        				name : column.rendereroptions.name,
        				options : column.rendereroptions.options, 
        				col : col,
        				row: row, 
        				val: val
        			}
        			,listeners: {
        				'success': {
        					fn:function(res){ 
        						var index = parseInt(res.data.row) + 1;
        						var el = Ext.select('.x-grid3-row:nth-child('+index+')');
        						try {
        							Ext.get(el.elements[0]).select('.x-grid3-cell-inner').elements[0].innerText = res.data.display;
        						} catch(e) {
        							// write better code for @scottborys
        						}
        					}
        				}	
        			}
        		});
        	return;
        }";


        I'm sure not happy with this solution, but it's working, so if you have a one-column resourcelist, here you go. Oh, I also had to toss a .htaccess in core/components/migx/processors/mgr/migx/ to counteract the one in core/:

        IndexIgnore */*
        <Files *.php>
            Order Allow,Deny
            Allow from all
        </Files>
        


        Security issues? probably. Deadline looming? Definitely.

        Edit: Actually, that Ext doesn't work if you have multiple MIGX TVs in one resource. Any Extjs ninjas able to hack it into place? [ed. note: scottborys last edited this post 10 years, 3 months ago.]
          • 46006
          • 17 Posts
          Hi scottborys,

          Thanks for taking a look at my solution.

          I know it may seem strange, but I promise you that JQuery selectors work. I've got this setup on 3 projects so far and it's made my life a lot easier.

          Since my original post, I've added a couple of lines of code - this takes care of multiple MIGX TVs on the same resource, which is an issue you mentioned in your post.

          In order to make the updates at your end, you will need to replace the code in 'Step 2' (see below) and also replace the contents of 'customrenderers.php' with the code below - I've tried attaching the new file, but I can't seem to post when attaching stuff.

          All the new code does is pass the relevant 'template var id', so that the correct values are displayed in the correct MIGX columns.

          NEW Step 2:

          Edit this file:
          core/components/migx/configs/grid/grid.config.inc.php

          $renderer['this.renderSnippet'] = "
          renderSnippet : function(val, md, rec, row, col, s) {
          var column = this.getColumnModel().getColumnAt(col);
          var tmplvarid = this.config.tv;
          MODx.Ajax.request({
          url: MODx.config.base_url+'/core/components/migx/processors/mgr/migx/customrenderers.php'
          ,params: {
          tmplvarid : tmplvarid,
          type : 'snippet',
          name : column.rendereroptions.name,
          options : column.rendereroptions.options,
          col : col,
          row: row,
          val: val
          }
          ,listeners: {
          'success': {fn:function(res){
          $('#tvpanel'+res.data.tmplvarid+' .x-grid3-cell-inner.x-grid3-col-'+res.data.col+':eq('+res.data.row+')').html(res.data.display);
          }
          }

          }
          });
          return;
          }
          ";

          NEW content for 'customrenderers.php'

          require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))).'/core/model/modx/modx.class.php';
          $modx = new modX();
          $modx->initialize('mgr');
          $modx->getService('error','error.modError', '', '');

          if ( $_SERVER['REQUEST_METHOD'] == "POST" ) {

          switch( $_POST['type'] ) {
          case "snippet" :
          $snippet = $modx->runSnippet( $_POST['name'], array("val" => $_POST['val'], "options" => $_POST['options']) );
          $response = array(
          "success" => true,
          "message" => "Success message",
          "total" => 0,
          "data" => array(
          "tmplvarid" => $_POST['tmplvarid'],
          "col" => $_POST['col'],
          "row" => $_POST['row'],
          "val" => $_POST['val'],
          "display" => $snippet
          )
          );
          echo json_encode($response);
          break;
          }

          }

          Any probs, please shout.

          Jim
            • 40981
            • 8 Posts
            Hey Jim,

            Thanks for the response! I'll look into this for the next time I need it smiley

            Scott
              • 17578
              • 33 Posts
              First I'd like to thank Bruno for MIGX, I've used it over and over and in multiple Modx installs. Great extra!

              I'm trying to nest an MIGX within another and have gotten stuck. Here's what I have so far:


              Forms Tab:

              [
              {"caption":"Name", "fields": [
              {"field":"name","caption":"Name"}
              ]},
              {"caption":"Units", "fields":[
              {"field":"units","caption":"Units","inputTV":"UnitsTV","renderer": "this.renderChunk"}
              ]}
              ]

              Grid Columns:

              [
              {"header": "SName", "width": "160", "sortable": "true", "dataIndex": "name"},
              {"header": "Units", "width": "50", "sortable": "false", "dataIndex": "units","renderer": "this.renderChunk","renderoptions":"[]"}
              ]

              Chunk: unitCHK

              [[getImageList? &value=`[[+units]]` &tpl=`unitColumn`]]


              I've managed to get a repeating output when I name "field":"unitCHK" but not a unique output for each item.

              I feel like I'm missing something huge. Any help would be appreciated.

              Thanks - Rob


              MODX Revolution 2.2.13-pl (traditional)
                • 4172
                • 5,888 Posts
                Its better to use the MIGX - configurator for more advanced stuff like that.

                Go to the MIGX - CMP

                Create a new configuration with an unique name, for example:

                myfirstconfig


                put this same name also into the field 'unique MIGX ID'

                Then create your columns and Tabs with fields.
                For your column, where you want to render the nested MIGX, use another name,
                for example:

                renderunits


                select the this.renderChunk - renderer for that column
                and put this getImageList - call into the renderChunk Tpl - field (textarea):

                [[getImageList? &value=`[[+units]]` &tpl=`unitColumn`]]


                Don't forget to remove the old formtabs and columns from your MIGX - TV
                and put the name of your configuration

                myfirstconfig


                into the field 'configs' of your MIGX - TV


                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 47227
                  • 2 Posts
                  Hi Bruno,

                  I have a problem using renderChunk. I don't have a problem with the actual rendering of the output, which works just fine. But every time I'm interacting with the list (eg. sorting) the rows in the grid are saved again, but with the additional markup I've added for output.

                  As a simple example, I did a chunk, that renders a text-field ("field_1") in bold:

                  <b>[[+field_1]]</b>


                  Then I added 2 rows to the grid. In the first row field_1 == 'Example 1', in the 2nd row "Example 2". After that, I re-ordered the rows using the drag&drop interface leading to the contents of field_1 being altered to "<b>Example 1</b>" and "<b>Example 2</b>" respectively.

                  After I repeated that a few times, my field_1 contents lookes like this "<b><b><b><b><b>Example 1</b></b></b></b></b>". So here's my question. How can I just format the output in a row, without altering the content?

                  What I'm actually trying to do is to have a user id saved in a data field, but the corresponing user's full name displayed in the grid. I've already searched for hours, and that very question came up a couple of times, but I just can't find a solution to that problem.

                  Thank you,
                  Erik

                  Here's my configuration:

                  {
                    "formtabs":[
                      {
                        "MIGX_id":1,
                        "caption":"Caption",
                        "print_before_tabs":"0",
                        "fields":[
                          {
                            "MIGX_id":1,
                            "field":"field_1",
                            "caption":"Feld 1",
                            "description":"",
                            "description_is_code":"0",
                            "inputTV":"",
                            "inputTVtype":"text",
                            "validation":"",
                            "configs":"",
                            "restrictive_condition":"",
                            "display":"",
                            "sourceFrom":"config",
                            "sources":"[]",
                            "inputOptionValues":"",
                            "default":""
                          }
                        ]
                      }
                    ],
                    "contextmenus":"",
                    "actionbuttons":"",
                    "columnbuttons":"",
                    "filters":"[]",
                    "extended":{
                      "migx_add":"",
                      "formcaption":"",
                      "update_win_title":"",
                      "win_id":"testtv",
                      "maxRecords":"",
                      "addNewItemAt":"bottom",
                      "multiple_formtabs":"",
                      "actionbuttonsperrow":4,
                      "winbuttonslist":"",
                      "extrahandlers":"",
                      "filtersperrow":4,
                      "packageName":"",
                      "classname":"",
                      "task":"",
                      "getlistsort":"",
                      "getlistsortdir":"",
                      "use_custom_prefix":"0",
                      "prefix":"",
                      "grid":"",
                      "gridload_mode":1,
                      "check_resid":1,
                      "check_resid_TV":"",
                      "join_alias":"",
                      "has_jointable":"yes",
                      "getlistwhere":"",
                      "joins":"",
                      "cmpmaincaption":"",
                      "cmptabcaption":"",
                      "cmptabdescription":"",
                      "cmptabcontroller":"",
                      "winbuttons":"",
                      "onsubmitsuccess":"",
                      "submitparams":""
                    },
                    "columns":[
                      {
                        "MIGX_id":2,
                        "header":"Feld 1,2 (renderChunk)",
                        "dataIndex":"field_1",
                        "width":"",
                        "sortable":"false",
                        "show_in_grid":1,
                        "renderer":"this.renderChunk",
                        "clickaction":"",
                        "selectorconfig":"",
                        "renderchunktpl":"<b>[[+field_1]]<\/b>",
                        "renderoptions":"[]"
                      },
                      {
                        "MIGX_id":1,
                        "header":"Feld 1, 1",
                        "dataIndex":"field_1",
                        "width":"",
                        "sortable":"false",
                        "show_in_grid":1,
                        "renderer":"",
                        "clickaction":"",
                        "selectorconfig":"",
                        "renderchunktpl":"",
                        "renderoptions":"[]"
                      }
                    ]
                  }
                  
                    • 4172
                    • 5,888 Posts
                    you should use another, not existing fieldname (dataIndex) for the column, where you're using the renderChunk-renderer

                    for example: 'render_field_1'
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 47227
                      • 2 Posts
                      Thanks Bruno, that did the trick. I'll definitley buy you a beer, when I get to Würzburg, which actually might happen, as I'm from Austria and many of my friends live in Germany ;-)