vitmalina / w2ui

UI widgets for modern apps. Data table, forms, toolbars, sidebar, tabs, tooltips, popups. All under 120kb (gzipped).
http://w2ui.com
MIT License
2.64k stars 730 forks source link

W2UI 2.0 - render funtion doesn't work for column "type": "checkbox" #2462

Closed jankrnavek closed 7 months ago

jankrnavek commented 10 months ago

I tried to use a custom render function for the column "type": "checkbox", but without success. I still see the standard HTML checkbox. Where am I wrong, or is it a bug?

Column definition:

 {
    min: "20",
    size: "28px", 
    sortable: True,
    resizable: False,
    autoResize: False,
    searchable: False,
    field: "star",
    text: '<span class="fa-regular fa-star"></span>',
    hidden: False,
    hideable: True,
    editable": {"type": "checkbox", "style": "text-align: center"},
    render(record, extra) {
    if (extra.value) {
        return '<span class="fa fa-star"></span>'
    } else {
        return '<span class="fa-regular fa-star"></span>'
    }
    }
}
provision95 commented 10 months ago

1)you have a type in editable - remove ' " ' 2)render is an object key, so it must be set as: render: (rec,ext) => {} or render: function(rec,ext){}

jankrnavek commented 9 months ago

Sorry for typos. The previous code I wrote by hand. The new one doesn't work as well. (see below)

 {
    min: "20",
    size: "28px", 
    sortable: true,
    resizable: false,
    autoResize: false,
    searchable: false,
    field: "star",
    text: '<span class="fa-regular fa-star"></span>',
    hidden: false,
    hideable: true,
    editable: {"type": "checkbox", "style": "text-align: center"},
    render: function(record, extra) {
    if (extra.value) {
        return '<span class="fa fa-star"></span>'
    } else {
        return '<span class="fa-regular fa-star"></span>'
    }
    }
}
vitmalina commented 8 months ago

Well, editable fields do not support custom renderers on top. If you do use your own renderer, then you can implement your own logic for editable fields.

Here is a JS Fiddle https://jsfiddle.net/chax2j4k/2/