MODX Community

MIGX: (still) impossible to format inputs using renderChunk in columns view?

I (like many others) would like to format inputs like a date or really anything using the renderChunk option in the columns view of MIGX (not MIGX DB!).

I’ve read a ton of other posts about this, I’ve tried copying working solutions from an actual MIGX DB build, but I couldn’t find a working solution. I really don’t want to set up a full featured MIGX DB only because I want a date to not have the default format.

Here is an example which should work (but doesn’t):

// Formtabs
{"field":"date","caption":"Date","inputTVtype":"date"}
// Grid Columns
{"header": "Date", "width": "50", "sortable": "true", "dataIndex": "dateRender","renderer": "this.renderChunk","renderchunktpl": "renderDate"}
// renderDate Chunk
[[+date:strtotime:date=`%A, %d.%m.%Y`]]

Is it really not possible to accomplish this? (And if so why?)

should be possible by setting up a migx - config, like you would do for migxdb.
Then don’t use the formtabs and columns - field, but put the name of the migx - configuration into the configs - input-option of your migx - TV

1 Like

Just to be clear, I still have to go through the whole package creation process, right? Because I tried creating just the config and linking it to the TV, but it doesn’t keep the data (to be exact it only saves one data entry per column). I would’ve hoped it could still save the inputs in the TV itself. Is there something I’m missing like a setting in the configs or do I have to setup a complete new package then?

you don’t need to create a package. Just the configuration.
could you post your exported config, please (the whole json-thing)?

{
  "formtabs":[
    {
      "MIGX_id":1,
      "caption":"Termin",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":1,
          "field":"date",
          "caption":"Datum",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"date",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":2,
          "field":"type",
          "caption":"Art",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"listbox",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"Kochkurs||Men\u00fcabend",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":3,
          "field":"title",
          "caption":"Name",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":4,
          "field":"text",
          "caption":"Beschreibung",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"textarea",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        }
      ],
      "pos":1
    },
    {
      "MIGX_id":2,
      "caption":"Bild",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":5,
          "field":"image",
          "caption":"Bild",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"image",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":2
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "media_source_id":"",
    "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":"Datum",
      "dataIndex":"date",
      "width":50,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"[[+date:strtotime:date=`%A, %d.%m.%Y`]]",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Art",
      "dataIndex":"type",
      "width":50,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Name",
      "dataIndex":"title",
      "width":200,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":4,
      "header":"Bild",
      "dataIndex":"image",
      "width":50,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ],
  "category":""
}

give your rendered column another dataIndex, for example:

{
      "MIGX_id":1,
      "header":"Datum",
      "dataIndex":"rendered_date",
      "width":50,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"[[+date:strtotime:date=`%A, %d.%m.%Y`]]",
      "renderoptions":"",
      "editor":""
    }
1 Like

Oh right, I thought about that in my first example but forgot now. Works great now, thanks a lot!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.