def _get_properties(self, source): props = { p: getattr(self, p) for p in list(Layoutable.param) if getattr(self, p) is not None } if props.get('height', None) is None: data = source.data length = max([len(v) for v in data.values()]) if data else 0 props['height'] = min([length * self.row_height + 30, 2000]) if self.hierarchical: props['target'] = ColumnDataSource( data=dict(row_indices=[], labels=[])) props['grouping'] = self._get_groupings() props['source'] = source props['columns'] = self._get_columns() props['index_position'] = None props['fit_columns'] = self.fit_columns if 'autosize_mode' in DataTable.properties(): props['frozen_columns'] = self.frozen_columns props['frozen_rows'] = self.frozen_rows props['autosize_mode'] = self.autosize_mode props['auto_edit'] = self.auto_edit props['row_height'] = self.row_height props['editable'] = not self.disabled and len(self.indexes) <= 1 props['sortable'] = self.sortable props['reorderable'] = self.reorderable return props
def _get_properties(self): props = { p: getattr(self, p) for p in list(Layoutable.param) if getattr(self, p) is not None } df = self.value.reset_index() if len(self.indexes) > 1 else self.value if df is None: data = {} else: data = { k if isinstance(k, str) else str(k): v for k, v in ColumnDataSource.from_df(df).items() } if props.get('height', None) is None: length = max([len(v) for v in data.values()]) if data else 0 props['height'] = length * self.row_height + 30 if self.hierarchical: props['target'] = ColumnDataSource( data=dict(row_indices=[], labels=[])) props['grouping'] = self._get_groupings() props['source'] = ColumnDataSource(data=data) props['columns'] = self._get_columns() props['index_position'] = None props['fit_columns'] = self.fit_columns if 'autosize_mode' in DataTable.properties(): props['frozen_columns'] = self.frozen_columns props['frozen_rows'] = self.frozen_rows props['autosize_mode'] = self.autosize_mode props['auto_edit'] = self.auto_edit props['row_height'] = self.row_height props['editable'] = not self.disabled and len(self.indexes) == 1 props['sortable'] = self.sortable props['reorderable'] = self.reorderable return props