for the volkovlabs business table say I have an empty table when I want to add a row the fields to add a row are empty however when the table is populated the fields appear is this a bug or intended behavior . I would create an issue in github but that all but seems to be taken down. I will also work on it and make a PR if I solve it
I have the same experience. But due to lack of time and knowledge of Grafana internals I solved this by using a form for adding a record. But I guess the source of this problem is in Grafana - because when the returned dataset is empty, it doesn’t send not even metadata about the set (columns etc…) so even for standard table the table is missing columns.
Hey I have been working on business-table for some time now, I am looking at the react hook responsible for the columns and so far when there is no data, the columns get filtered out . Would you like to get or a slack call to help me find the source of the issue?
Not sure if I will be any usefull, because I’m definitely a newbie when it comes to Grafana internals. I just sometimes looked at the JSON response to the request of data loading. The target endpoint is /query which belongs to the Grafana core and when it returns empty dataset it looks like: {
"results": {
"A": {
"status": 200,
"frames": [
{
"schema": {
"refId": "A",
"meta": {
"typeVersion": [
0,
0
],
"executedQueryString": "my SQL query"
},
"fields": []
},
"data": {
"values": []
}
}
]
}
}
} and that’s the source of the problem I guess. For the businessTable it could somehow work, because it has independent definition of columns. But I cannot help you with this as I’m not digged into BT sources.
the problem is with business-table for grafana not grafana itself, what happens is when the table has no rows the code catnt determine the issue with the columns
Sure, but this could be cause by response from Grafana which contains no data nor fields definitions. Not sure how business table handles such a situation internally. All I know it acts nearly same as built-in table.
The columns are provided but they are filtered out
SOLVED useTable.tsx
// .map((config) => ({
// config,
// field: frame.fields.find((field) => filterFieldBySource(frame, field, config.field)),
// }))
// .filter((item) => !!item.field) as Array<{ config: ColumnConfig; field: Field }>;
const items = columnsConfig
.map((config) => {
const field = frame.fields.find((field) => filterFieldBySource(frame, field, config.field));
// If no field found, create a dummy field to maintain column structure
console.log(field)
if (!field) {
const fieldName = typeof config.field === 'string' ? config.field : config.field.name;
return {
config,
field: {
name: fieldName,
type: FieldType.string,
config: {},
values: [],
} as Field
};
}
return { config, field };
});```