json-forms icon indicating copy to clipboard operation
json-forms copied to clipboard

Rendering in DIVs not Tables

Open kokujin opened this issue 8 years ago • 2 comments

Is it possible to configure json-forms to reder forms in DIVS or another container instead of a table? Thanks

kokujin avatar Aug 03 '16 18:08 kokujin

Sorry @kokujin it cannot be changed with the current implementation, but shouldn't be difficult to do.

idelvall avatar Aug 04 '16 09:08 idelvall

@kokujin

You can accomplish the required by doing the following.

code start line: 511 in js file

var table = document.createElement("div");
            table.className = "row";
            var tbody = document.createElement("tbody");
            appendChild(table, tbody, s);
            var propNum = 0;
            if (s.hasOwnProperty("properties")) {
                propNum = s.properties.length;
                for (var prop in s.properties) {
                    var tr = document.createElement("div");
                    tr.className = "col-xs-12 col-sm-6 form-group";
                    var td1 = document.createElement("div");
                    td1.className = "m-t-md";
                    var propId = id + "." + prop;
                    var td2 = document.createElement("div");
                    td2.className = " prop-value";
                    appendChild(tbody, tr, s);
                    appendChild(tr, td1, s);
                    appendChild(tr, td2, s);
                    var pp = createStaticPropertyProvider(prop);
                    var propInitialValue = null;
                    if (value) {
                        propInitialValue = value[prop];
                    }
                    render(td1, td2, propId, current, pp, propInitialValue);
                }
            }

mavvverick avatar Sep 27 '16 11:09 mavvverick