gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

Change the view of a row in a table dynamically #606

Open callkalpa opened 6 years ago

callkalpa commented 6 years ago

I am having following table. in postRender I iterate through all the field of the table and for them I set view to be bootstrap-display (if I set view to be bootstrap-display in tableRow, the Actions column is disappeared.)

screenshot from 2018-02-18 01-21-21

My intention is, when a user clicks Edit, the data of that row needs to be editable. What would be the way to get this done?

I tried to set view to be bootstrap-edit with the options, but that makes the fields of all rows editable where as my requirement is to make the fields in that row only editable.

WhileTrueEndWhile commented 6 years ago

Please try something like this schematic idea:

{
    ...
    "options": {
        "items": {
            "fields": {
                "COLUMN_WITH_BUTTON": {
                    "events": {
                        "click": function() {
                            this.parent.view.parent = "bootstrap-edit";
                            this.parent.refresh();
                        }
                    }
                }
            }
        }
    },
    ...
}