Bruno17 / MIGX

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

this.renderChunk field wrong re-render on dragging / sorting rows. #275

Open dimitrihilverda opened 7 years ago

dimitrihilverda commented 7 years ago

I use this.renderChunk to display an image by using a fieldname as image name like this:

<img src="/static/adwise/media/images/mig-x_descriptions/[[+chunk-name]].jpg" title="[[+chunk-name]]" />

This works until I drag and drop a row then it gets broken: before drag:

<div class="x-grid3-cell-inner x-grid3-col-2"><img src="/static/adwise/media/images/mig-x_descriptions/block_image-comparison.jpg" title="block_image-comparison"></div>

after:

<div class="x-grid3-cell-inner x-grid3-col-2"><img src="/static/adwise/media/images/mig-x_descriptions/&lt;img src=" static="" adwise="" media="" images="" mig-x_descriptions="" block_image-comparison.jpg"="" title="block_image-comparison">.jpg" title="<img src="/static/adwise/media/images/mig-x_descriptions/block_image-comparison.jpg" title="block_image-comparison">" /&gt;</div>

It looks like there is maybe some stuff stripped and replaced in the wrong place?

Bruno17 commented 7 years ago

what is your whole MIGX-configuration?

dimitrihilverda commented 7 years ago

I have a huge config, I use multiple migx configs with multiple formtabs, do you need also all the formtabs?

Bruno17 commented 7 years ago

maybe just the columns is enough

dimitrihilverda commented 7 years ago

I think that the problem is as follows:

I use a fieldname from a 2nd migx that I use in the multiple migx configs, called chunk-name, the problem I created was that I used this also as fieldname in columns while I only needed it in the renderer.:

{
  "formtabs":[
    {
      "MIGX_id":3,
      "caption":"",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":13,
          "field":"content_main-title",
          "caption":"content_main-title",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"Inhoudsblok toevoegen",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"migx_holder",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"5||6||7||9||10||11||12||14||16||17||18||20||21",
    "multiple_formtabs_label":"Selecteer het type block dat je wilt aanmaken",
    "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":"Soort veld",
      "dataIndex":"MIGX_formname",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Titel",
      "dataIndex":"title",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Block voorbeeld",
      "dataIndex":"chunk-name",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"<img src=\"\/static\/adwise\/media\/images\/mig-x_descriptions\/[[+chunk-name]].jpg\" title=\"[[+chunk-name]]\" \/>",
      "renderoptions":"",
      "editor":""
    }
  ]
}

as you can see the dataindex chunk-name is used but that name is also used in the inner migx config:

{
  "formtabs":[
    {
      "MIGX_id":5,
      "caption":"",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":20,
          "field":"chunk-name",
          "caption":"Naam chunk",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"none",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"block_image-comparison",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":89,
          "field":"uitleg",
          "caption":"Uitleg",
          "description":"[[$description_image-comparison]]",
          "description_is_code":1,
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":21,
          "field":"fields_image-comparison",
          "caption":"afbeelding vergelijker",
          "description":"",
          "description_is_code":"0",
          "inputTV":"migx_image-comparison",
          "inputTVtype":"migx",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"Voor een vergelijking toe",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"Afbeelding vergelijker",
    "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":""
}

as you can see in the export above. This messed things up, but only when I re-arranged the rows.

Now I changed the fieldname voor the column to a nonexisting fieldname (block_example) and now it works without problems.:

{
  "formtabs":[
    {
      "MIGX_id":3,
      "caption":"",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":13,
          "field":"content_main-title",
          "caption":"content_main-title",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"Inhoudsblok toevoegen",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"migx_holder",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"5||6||7||9||10||11||12||14||16||17||18||20||21",
    "multiple_formtabs_label":"Selecteer het type block dat je wilt aanmaken",
    "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":"Soort veld",
      "dataIndex":"MIGX_formname",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Titel",
      "dataIndex":"title",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Block voorbeeld",
      "dataIndex":"block_example",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"<img src=\"\/static\/adwise\/media\/images\/mig-x_descriptions\/[[+chunk-name]].jpg\" title=\"[[+chunk-name]]\" \/>",
      "renderoptions":"",
      "editor":""
    }
  ]
}