We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52884
    • 25 Posts
    Hi,

    I successfully managed to create a nested migx tv:
    A child migx tv, containing a textfield and a dropdown (other tv 1).
    A parent migx tv, containing a dropdown (other tv 2) and the child migx tv.

    In the table of the parent tv, I want to show 3 columns:
    1: value of other tv 2
    2: value of child tv where other tv 1 has the value "Default"
    3: number of items from child tv.

    I think 2+3 would require a custom renderer, so my table code for the parent tv looks like this:
    [  {    "header":"Partner",    "dataIndex":"ptv_heading"  },
    {    "header":"Default Link",    "dataIndex":"ptv_childtv", "renderer":"this.renderDefItem"  },
    {    "header":"Number of Links",    "dataIndex":"ptv_childtv", "renderer":"this.renderCountItems"  } ]
    


    This is the code I wrote for the custom renderers
    $renderer['this.renderCountItems'] = "
    renderFirst : function(val, md, rec, row, col, s){
            var obj = JSON.parse(val);
            var size = 0, key;
            for (key in obj) {
            if (obj.hasOwnProperty(key)) size++;
        }
       return size;
        }        
    ";
    
    $renderer['this.renderDefItem'] = "
    renderFirst : function(val, md, rec, row, col, s){
        var items = JSON.parse(val);
        var results = items.filter(function(obj) { return obj.ctv_country == 'Default'; });
        for (var i = 0; i < results.length; i++) {
            var deflink = results[i].ctv_url;
        }
        if (deflink) {
            var outputtxt = deflink;
        }
        else {
            var outputtxt = '';
        }
        return outputtxt;
        }        
    ";
    



    My questions:
    Where do I have to include my custom renderers? grid.renderer.inc.php or grid.custom.config.inc.php or both?
    Unfortunately, my example is not working, no matter where I put my code. the table cell for the column shows the json string instead:

    [{"MIGX_id":"1","ctv_url":"dfgdfg","ctv_country":"Default"},{"MIGX_id":"2","ctv_url":"dfgdfgfdg","ctv_country":"Germany"}]
    


    Any ideas?

    Perhaps it might be better to use Migxdb instead to create everything via the CMP, however, I am struggling with how to set up a nested migxdb tv. Any help with this would be much appreciated!

    Best regards,
    Nico
      • 4172
      • 5,888 Posts
      For the renderer - question, I would simply use the this.renderChunk - renderer and put a getImageList - or other snippet into the renderchunk - tpl within the MIGX-config.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 52884
        • 25 Posts
        Hi Bruno,

        this sounds logical, however, it still shows the json string, even with a simple chunk only containing the word "test". Am I missing something in the table code?
        I am using MIGX 2.9.6 and Modx 2.5.0

        [  {    "header":"Partner",    "dataIndex":"ptv_heading" },
        {    "header":"Default Link",    "dataIndex":"ptv_childtv", "renderer":"this.renderChunk", "renderchunktpl":"testchunk1"  } },
        {    "header":"Weitere Links",    "dataIndex":"ptv_childtv", "renderer":"this.renderChunk", "renderchunktpl":"testchunk2"  } ]
        


          • 4172
          • 5,888 Posts
          into the renderchunktpl, you put the snippet-call or other MODX-tags, something like

          [[getImageList?
          &value=`[[+ptv_childtv]]`
          &tpl=`testchunk1`
          ]]
          


          and your dataIndex needs to be different from your original field-name

          {    "header":"Default Link",    "dataIndex":"renderchildtv", "renderer":"this.renderChunk", "renderchunktpl":"[[getImageList?&value=`[[+ptv_childtv]]`&tpl=`testchunk1`]]"  } },


          I think, it is easier to use the MIGX-configurator to set this up
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 52884
            • 25 Posts
            Hi Bruno,

            I was able to set this up successfully via the MIGX-configurator. It is working pretty nicely, however, each time I add another item for a table row, the snippet-call seems to be executed again.

            If I have one item in the table which has 3 items in it, each with a default url called "DefaultURL", the table column cell has the value "DefaultURLDefaultURLDefaultURL".

            Can I prevent this somehow, maybe via the Renderoptions?
              • 4172
              • 5,888 Posts
              could you post your configs, what you have now, please
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 52884
                • 25 Posts
                Sure,

                Parent TV:

                {
                  "formtabs":[
                    {
                      "MIGX_id":9,
                      "caption":"Partnerlinks",
                      "print_before_tabs":"0",
                      "fields":[
                        {
                          "MIGX_id":15,
                          "field":"partner",
                          "caption":"Partner",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"SLServiceDD",
                          "inputTVtype":"",
                          "validation":"",
                          "configs":"",
                          "restrictive_condition":"",
                          "display":"",
                          "sourceFrom":"config",
                          "sources":"",
                          "inputOptionValues":"",
                          "default":"",
                          "useDefaultIfEmpty":"0",
                          "pos":1
                        },
                        {
                          "MIGX_id":16,
                          "field":"links",
                          "caption":"Links",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"SLShoplinkURL",
                          "inputTVtype":"",
                          "validation":"",
                          "configs":"",
                          "restrictive_condition":"",
                          "display":"",
                          "sourceFrom":"config",
                          "sources":"",
                          "inputOptionValues":"",
                          "default":"",
                          "useDefaultIfEmpty":"0",
                          "pos":2
                        }
                      ],
                      "pos":1
                    }
                  ],
                  "contextmenus":"",
                  "actionbuttons":"",
                  "columnbuttons":"",
                  "filters":"",
                  "extended":{
                    "migx_add":"Partner hinzuf\u00fcgen",
                    "disable_add_item":"",
                    "add_items_directly":"",
                    "formcaption":"",
                    "update_win_title":"Partner Links",
                    "win_id":"lp-shopservices",
                    "maxRecords":"",
                    "addNewItemAt":"bottom",
                    "multiple_formtabs":"",
                    "multiple_formtabs_label":"",
                    "multiple_formtabs_field":"",
                    "multiple_formtabs_optionstext":"",
                    "multiple_formtabs_optionsvalue":"",
                    "actionbuttonsperrow":4,
                    "winbuttonslist":"",
                    "extrahandlers":"",
                    "filtersperrow":4,
                    "packageName":"",
                    "classname":"",
                    "task":"",
                    "getlistsort":"",
                    "getlistsortdir":"",
                    "sortconfig":"",
                    "gridpagesize":"",
                    "use_custom_prefix":"0",
                    "prefix":"",
                    "grid":"",
                    "gridload_mode":1,
                    "check_resid":1,
                    "check_resid_TV":"",
                    "join_alias":"",
                    "has_jointable":"yes",
                    "getlistwhere":"",
                    "joins":"",
                    "hooksnippets":"",
                    "cmpmaincaption":"",
                    "cmptabcaption":"",
                    "cmptabdescription":"",
                    "cmptabcontroller":"",
                    "winbuttons":"",
                    "onsubmitsuccess":"",
                    "submitparams":""
                  },
                  "columns":[
                    {
                      "MIGX_id":1,
                      "header":"Partner",
                      "dataIndex":"partner",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "customrenderer":"",
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderchunktpl":"",
                      "renderoptions":"",
                      "editor":""
                    },
                    {
                      "MIGX_id":2,
                      "header":"Default Link",
                      "dataIndex":"linksdef",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "customrenderer":"",
                      "renderer":"this.renderChunk",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderchunktpl":"[[getImageList?\n&value=`[[+links]]`\n&tpl=`migxdefurl`\n]]",
                      "renderoptions":"",
                      "editor":""
                    },
                    {
                      "MIGX_id":3,
                      "header":"Weitere Links",
                      "dataIndex":"alllinks",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "customrenderer":"",
                      "renderer":"this.renderChunk",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderchunktpl":"[[getImageList?\n&value=`[[+links]]`\n&tpl=`migxmoreurl`\n]]",
                      "renderoptions":"",
                      "editor":""
                    }
                  ]
                }
                



                Child TV (SLShoplinkURL):
                {
                  "formtabs":[
                    {
                      "MIGX_id":8,
                      "caption":"Shop URL",
                      "print_before_tabs":"0",
                      "fields":[
                        {
                          "MIGX_id":13,
                          "field":"url",
                          "caption":"Ziel URL",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"",
                          "validation":"",
                          "configs":"",
                          "restrictive_condition":"",
                          "display":"",
                          "sourceFrom":"config",
                          "sources":"",
                          "inputOptionValues":"",
                          "default":"",
                          "useDefaultIfEmpty":"0",
                          "pos":1
                        },
                        {
                          "MIGX_id":14,
                          "field":"country",
                          "caption":"Land",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"SLCountryDD",
                          "inputTVtype":"",
                          "validation":"",
                          "configs":"",
                          "restrictive_condition":"",
                          "display":"",
                          "sourceFrom":"config",
                          "sources":"",
                          "inputOptionValues":"",
                          "default":"",
                          "useDefaultIfEmpty":"0",
                          "pos":2
                        }
                      ],
                      "pos":1
                    }
                  ],
                  "contextmenus":"",
                  "actionbuttons":"",
                  "columnbuttons":"",
                  "filters":"",
                  "extended":{
                    "migx_add":"Ziel URL hinzuf\u00fcgen",
                    "disable_add_item":"",
                    "add_items_directly":"",
                    "formcaption":"",
                    "update_win_title":"Shop URLs",
                    "win_id":"lp-shopurls",
                    "maxRecords":"",
                    "addNewItemAt":"bottom",
                    "multiple_formtabs":"",
                    "multiple_formtabs_label":"",
                    "multiple_formtabs_field":"",
                    "multiple_formtabs_optionstext":"",
                    "multiple_formtabs_optionsvalue":"",
                    "actionbuttonsperrow":4,
                    "winbuttonslist":"",
                    "extrahandlers":"",
                    "filtersperrow":4,
                    "packageName":"",
                    "classname":"",
                    "task":"",
                    "getlistsort":"",
                    "getlistsortdir":"",
                    "sortconfig":"",
                    "gridpagesize":"",
                    "use_custom_prefix":"0",
                    "prefix":"",
                    "grid":"",
                    "gridload_mode":1,
                    "check_resid":1,
                    "check_resid_TV":"",
                    "join_alias":"",
                    "has_jointable":"yes",
                    "getlistwhere":"",
                    "joins":"",
                    "hooksnippets":"",
                    "cmpmaincaption":"",
                    "cmptabcaption":"",
                    "cmptabdescription":"",
                    "cmptabcontroller":"",
                    "winbuttons":"",
                    "onsubmitsuccess":"",
                    "submitparams":""
                  },
                  "columns":[
                    {
                      "MIGX_id":1,
                      "header":"Ziel URL",
                      "dataIndex":"url",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "customrenderer":"",
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderchunktpl":"",
                      "renderoptions":"",
                      "editor":""
                    },
                    {
                      "MIGX_id":2,
                      "header":"Land",
                      "dataIndex":"country",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "customrenderer":"",
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderchunktpl":"",
                      "renderoptions":"",
                      "editor":""
                    }
                  ]
                }
                
                [ed. note: balihoo last edited this post 6 years, 8 months ago.]
                  • 52884
                  • 25 Posts
                  Update: The problem still exists after an MIGX update to 2.11.0.
                    • 4172
                    • 5,888 Posts
                    what is in your chunks migxdefurl and migxmoreurl?
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 46073
                      • 65 Posts
                      Has anyone ever successfully got the
                      "renderer":"this.renderChunk","renderchunktpl":"[[+example]]"
                      to work in the MIGX TV? It sounds like everyone gives up and uses the Config instead, which magically works. I'd really like to get it working in the main TV JSON.

                      Also, where do we configure the
                      "columnbuttons":""
                      in the MIGX TV?