Bruno17 / MIGX

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

this.renderSwitchStatusOptions doesn't work in MIGXdb config #249

Closed hugopeek closed 8 years ago

hugopeek commented 8 years ago

I want to create a toggle button in the grid for setting a value to 1 or 0 for a MIGX field, but I can't get it to work with the this.renderSwitchStatusOptions renderer.. I've done this before on a regular config with the same settings, but somehow that won't fly with MIGXdb now.

The error in the inspector reads:

Uncaught TypeError: Cannot read property 'createDelegate' of undefined

I tried setting the click actions on the item and on the individual renderOptions, but that doesn't help. Also added underscores to the names of the renderOptions, just in case..

This is my MIGX config:

{
  "formtabs":[
    {
      "MIGX_id":10,
      "caption":"Name and classification",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":38,
          "field":"name",
          "caption":"Common name",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":39,
          "field":"name_local",
          "caption":"Local name",
          "description":"What do you call this in your local language or dialect?",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":40,
          "field":"name_scientific",
          "caption":"Scientific name",
          "description":"For the real gardenerds amongst us ;)",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":41,
          "field":"category",
          "caption":"Category",
          "description":"And yes, yes, we know: a tomato is technically a fruit... But nevertheless, we are following the ruling of the U.S. Supreme Court of 1893, stating that a tomato is a vegetable \"because people think it is\". So in case of doubt, let that be your rule of thumb :)",
          "description_is_code":"0",
          "inputTV":"inventory_item_category",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        },
        {
          "MIGX_id":42,
          "field":"subcategory",
          "caption":"Subcategory",
          "description":"Here you can specify the exact type of seed. When set, it will become easier for us to hook this item up to related information, or to improve search and filter results for this type of food. If the subcategory is not in this list, you can manually add it under the Template Variables > Tags tab in your Farm Profile. You don't have to fill this in, but it will help generate a more complete list of food types in the system.",
          "description_is_code":"0",
          "inputTV":"inventory_item_subcategory",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":5
        }
      ],
      "pos":1
    },
    {
      "MIGX_id":11,
      "caption":"Origins",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":43,
          "field":"date_purchase",
          "caption":"Purchase date",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"date",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":44,
          "field":"date_packaging",
          "caption":"Packaging date",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"date",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":45,
          "field":"shelf_life",
          "caption":"Shelf life",
          "description":"How many years will this seed approximately last?",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"number",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":46,
          "field":"price_purchase",
          "caption":"Purchase price",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        },
        {
          "MIGX_id":47,
          "field":"source_name",
          "caption":"Name of the supplier",
          "description":"The company or person where you got these seeds from.",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":5
        },
        {
          "MIGX_id":48,
          "field":"source_info",
          "caption":"Contact info of supplier",
          "description":"So you can ask them for more, if their seeds are good :) This can be anything: website, address, phone number...",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"textarea",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":6
        }
      ],
      "pos":2
    },
    {
      "MIGX_id":12,
      "caption":"Performance",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":49,
          "field":"growing_method",
          "caption":"Growing method(s) used",
          "description":"Which type(s) of setup did you use for growing this seed?",
          "description_is_code":"0",
          "inputTV":"farm_profile_method",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":50,
          "field":"sowing_instructions",
          "caption":"Sowing instructions & tips",
          "description":"Can you share how you usually sow this seed? What type of soil do you use? How deep are you planting the seeds, how many per hole, and how far are they apart?",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"richtext",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":51,
          "field":"performance_notes",
          "caption":"Performance notes",
          "description":"How did this seed grow in your situation? Which factors affected performance? Are they sensitive to rain? Did you encounter any diseases? And how did the final produce taste?",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"richtext",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        }
      ],
      "pos":3
    },
    {
      "MIGX_id":13,
      "caption":"Presentation",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":52,
          "field":"image_main",
          "caption":"Main image",
          "description":"",
          "description_is_code":"0",
          "inputTV":"inventory_item_image",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":53,
          "field":"image_packaging",
          "caption":"Packaging image",
          "description":"This is completely optional, but it might come in handy someday to have a copy of the original package at hand.",
          "description_is_code":"0",
          "inputTV":"inventory_item_image",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":54,
          "field":"description",
          "caption":"Description",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"textarea",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        }
      ],
      "pos":4
    },
    {
      "MIGX_id":14,
      "caption":"Marketplace",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":55,
          "field":"published",
          "caption":"Show in marketplace",
          "description":"When activated, this seed will be added to the Grow Organics marketplace. It will show up on your profile page, in the general marketplace and possibly in other relevant locations. Before you turn this setting on, please make sure you fill out all the relevant fields below. If you keep this setting switched off, there won't be any publicly accessible references to this item.",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"option",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"Yes==1||No==0",
          "default":"0",
          "useDefaultIfEmpty":1,
          "pos":1
        },
        {
          "MIGX_id":56,
          "field":"trade_preference",
          "caption":"Preferred trading method",
          "description":"You can choose to sell this seed, but you can also exchange it for something else if you want, or give it away for free. Up to you!",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"option",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"Sell these seeds==sell||Exchange these seeds for something else==swap||Give them away for free==donate",
          "default":"sell",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":57,
          "field":"unit_measurement",
          "caption":"Unit of measurement",
          "description":"The price and available amount of this item will be based on this definition.",
          "description_is_code":"0",
          "inputTV":"inventory_item_unit_measurement",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":58,
          "field":"unit_price",
          "caption":"Unit price",
          "description":"Unit price is the price (in Pesos) for a single unit of measure of this item sold in more or less than the single unit. The \"unit price\" tells you the cost per kilogram, gram, or other unit of weight or volume.",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"number",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        },
        {
          "MIGX_id":59,
          "field":"unit_packaging",
          "caption":"Unit packaging",
          "description":"",
          "description_is_code":"0",
          "inputTV":"inventory_item_unit_packaging",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":5
        },
        {
          "MIGX_id":60,
          "field":"unit_quantity",
          "caption":"Unit amount",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"number",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":6
        },
        {
          "MIGX_id":61,
          "field":"stock_status",
          "caption":"Stock indication",
          "description":"",
          "description_is_code":"0",
          "inputTV":"inventory_item_stock_status",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":7
        }
      ],
      "pos":5
    }
  ],
  "contextmenus":"update||duplicate||recall_remove_delete",
  "actionbuttons":"addItem||toggletrash",
  "columnbuttons":"update||duplicate||recall_remove_delete",
  "filters":[
    {
      "MIGX_id":1,
      "name":"search",
      "label":"Search",
      "emptytext":"",
      "type":"textbox",
      "getlistwhere":"",
      "getcomboprocessor":"",
      "combotextfield":"",
      "comboidfield":"",
      "combowhere":"",
      "comboclassname":"",
      "combopackagename":"",
      "combo_use_custom_prefix":1,
      "comboprefix":"go_",
      "combojoins":"",
      "comboparent":"",
      "default":""
    }
  ],
  "extended":{
    "migx_add":"Add seeds",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"Add seeds",
    "win_id":"",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":3,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"grwrgnx-inventory",
    "classname":"InventorySeeds",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":1,
    "prefix":"go_",
    "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":"ID",
      "dataIndex":"id",
      "width":5,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Name",
      "dataIndex":"name_common",
      "width":40,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"[[$inventoryGridActionsSeeds? &name=`[[+name]]`]]",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Category",
      "dataIndex":"category",
      "width":30,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderChunk",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"[[getInputOptions?\n    &tv=`[[+category]]`\n]]",
      "renderoptions":"",
      "editor":"this.listboxEditor"
    },
    {
      "MIGX_id":4,
      "header":"Sell",
      "dataIndex":"published",
      "width":10,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderSwitchStatusOptions",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":[
        {
          "MIGX_id":2,
          "name":"dont_sell",
          "use_as_fallback":1,
          "value":"0",
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/cross.png"
        },
        {
          "MIGX_id":1,
          "name":"sell",
          "use_as_fallback":"",
          "value":1,
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/tick.png"
        },
        {
          "MIGX_id":3,
          "name":"dont_sell",
          "use_as_fallback":"",
          "value":"",
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/cross.png"
        }
      ],
      "editor":""
    },
    {
      "MIGX_id":7,
      "header":"Unit",
      "dataIndex":"unit_measurement",
      "width":15,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":"this.listboxEditor"
    },
    {
      "MIGX_id":8,
      "header":"Amount",
      "dataIndex":"unit_quantity",
      "width":20,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":"this.textEditor"
    },
    {
      "MIGX_id":6,
      "header":"Price",
      "dataIndex":"unit_price",
      "width":20,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":"this.textEditor"
    },
    {
      "MIGX_id":10,
      "header":"Image",
      "dataIndex":"image_main",
      "width":15,
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"ImagePlus.MIGX_Renderer",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":11,
      "header":"Stock",
      "dataIndex":"stock_status",
      "width":10,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"this.renderSwitchStatusOptions",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":[
        {
          "MIGX_id":2,
          "name":"out_of_stock",
          "use_as_fallback":1,
          "value":"0",
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/cross.png"
        },
        {
          "MIGX_id":1,
          "name":"in_stock",
          "use_as_fallback":"",
          "value":1,
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/tick.png"
        },
        {
          "MIGX_id":3,
          "name":"out_of_stock",
          "use_as_fallback":"",
          "value":"",
          "clickaction":"",
          "handler":"",
          "image":"assets\/components\/migx\/style\/images\/cross.png"
        }
      ],
      "editor":""
    },
    {
      "MIGX_id":9,
      "header":"Deleted",
      "dataIndex":"deleted",
      "width":5,
      "sortable":"false",
      "show_in_grid":"0",
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}
Bruno17 commented 8 years ago

you have to select the extrahandler 'this.handleColumnSwitch'

hugopeek commented 8 years ago

Ahhh, forgot about that one.. Thanks Bruno!