{"record":{"id":"9cfe88cb098c226b","repo":"reflex-dev/reflex","slug":"column-field-should-be-specified-when-the-data-fie","errorCode":null,"errorMessage":"column field should be specified when the data field is a list type","messagePattern":"column field should be specified when the data field is a list type","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-gridjs/src/reflex_components_gridjs/datatable.py","lineNumber":92,"sourceCode":"        ):\n            msg = \"Annotation of the computed var assigned to the column field should be provided.\"\n            raise ValueError(msg)\n\n        # If data is a pandas dataframe and columns are provided throw an error.\n        if (\n            types.is_dataframe(type(data))\n            or (isinstance(data, Var) and types.is_dataframe(data._var_type))\n        ) and columns is not None:\n            msg = \"Cannot pass in both a pandas dataframe and columns to the data_table component.\"\n            raise ValueError(msg)\n\n        # If data is a list and columns are not provided, throw an error\n        if (\n            (isinstance(data, Var) and types.typehint_issubclass(data._var_type, list))\n            or isinstance(data, list)\n        ) and columns is None:\n            msg = \"column field should be specified when the data field is a list type\"\n            raise ValueError(msg)\n\n        # Create the component.\n        return super().create(\n            *children,\n            **props,\n        )\n\n    def add_imports(self) -> ImportDict:\n        \"\"\"Add the imports for the datatable component.\n\n        Returns:\n            The import dict for the component.\n        \"\"\"\n        return {\"\": \"gridjs/dist/theme/mermaid.css\"}\n\n    def _render(self) -> Tag:\n        if isinstance(self.data, Var) and types.is_dataframe(self.data._var_type):\n            self.columns = self.data._replace(","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-gridjs/src/reflex_components_gridjs/datatable.py#L74-L110","documentation":"data_table cannot infer column definitions from plain list data — the list's contents have no schema. When data is a list-typed value, columns must be provided explicitly.","triggerScenarios":"rx.data_table(data=[[1, \"a\"], [2, \"b\"]]) or data=State.rows (list-typed var) without columns=...","commonSituations":"Switching from a DataFrame to a list of rows (e.g. after serialization or a fetch) and dropping the columns argument.","solutions":["Pass columns=[\"col1\", \"col2\"] (or column dicts) alongside list data","Or pass a pandas DataFrame instead, which derives columns automatically","For var data, annotate the state var as list[list[Any]] and still supply columns"],"exampleFix":"# before\nrx.data_table(data=State.rows)\n# after\nrx.data_table(data=State.rows, columns=[\"id\", \"name\"])","handlingStrategy":"validation","validationCode":"if (isinstance(data, list) or _is_list_var(data)) and columns is None:\n    columns = default_columns or ['col%d' % i for i in range(len(data[0]))]","typeGuard":"def is_list_data(data: Any) -> bool:\n    return isinstance(data, list) or (hasattr(data, '_var_type') and getattr(data._var_type, '__origin__', None) in (list,))","tryCatchPattern":null,"preventionTips":["Always pass columns with list data","Annotate list vars concretely: list[list[Any]]"],"tags":["reflex","gridjs","columns"],"backgroundTag":"missing-required-prop","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}