Skip to content

Table format for items doesn't respect propertyOrder  #143

@kotredes

Description

@kotredes

Regarding the recent propertyOrder change (discussed/added in #110 )

Applying properyOrder to an array with format: table, I see the headers get sorted to match the propertyOrder, but the editors for each of the items in the table do not.

As a simple example, below is a schema for an array whose items are objects, each with two properties, TextField and ChoiceField. (Both being strings, but with an enum for the ChoiceField, solely to make obvious what's happening)

This renders as a table with headings ordered TextField then ChoiceField, but the editors for the rows are ordered with the ChoiceField's values before the TextField

I suspect the error comes somewhere around https://github.com/jdorn/json-editor/blob/master/dist/jsoneditor.js#L2596 , where editor_holder is built based on this.schema.properties. Later in the code, if I'm reading it correctly, self.editors gets sorted. However, because the editor_holder was already generated, and not getting re-sorted, it renders in the original order, not the sorted order

Example: (Reproducible for me in http://jeremydorn.com/json-editor/)
Schema:

{
    "type": "object",
    "properties": {
        "OuterArray": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "FieldA": {
                        "type": "string",
                        "enum": [
                            "OptionA1",
                            "OptionA2"
                        ],
                        "propertyOrder": 10
                    },
                    "FieldB": {
                        "type": "string",
                        "propertyOrder": 5
                    }
                }
            },
            "format": "table"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions