I have a MySQL database with 10 rows. I run multiple names queries to make up multiple tables. Not all of there tables need all 10 rows. Is there a way to limit the number of rows displayed in a table either to a fixed number, or to not display row if value is "null" ?
If not, is there a way to remove the vertical scoll bar?
Here is my tables, and i.e, the bottom one, i want to only display 1 row.
You haven't shown your configuration so it's difficult to help you.
What is the root container type?
Are the tables dropped straight into the root container or are they embedded in something else?
Post one of the table configurations. In the Project Browser, right-click on a table component, copy, paste it in here, select the code block and press the </> formatting button.
When I want to limit the count of displayed rows, I either hard-code that limit in my Named Query, or I apply the following transform to my data (assuming a JSON data format):
I think the queries will only ever display a few rows. The problem is to eliminate the empty rows so that the tables auto-size to fit the non-empty rows. I'm waiting to see if my basis solution solves the problem.
These examples both strip out rows which have NoneType values OR boolean false values, or empty strings, and so might not be safe for all usages. They should be safe if all columns are strings/NoneType.
def transform(self, value, quality, timestamp):
# ALL columns of row must have value
max_rows = 3
original_pass = []
for row in value:
if all(row.values()):
original_pass.append(row)
return original_pass[0:max_rows]
def transform(self, value, quality, timestamp):
# ANY column of row may have value
max_rows = 3
original_pass = []
for row in value:
if any(row.values()):
original_pass.append(row)
return original_pass[0:max_rows]
@cmallonee, I take back my previous comment. I can see the bottom table is displaying one row but the alternate row background colors indicate that there are many empty rows in the table.
The database is fixed at 10 rows, where all rows are blank, until data is pushed into the database. The data thats gets pushed into database only fills up some of the rows (not fixed number, but <10). Therefore I want to display the rows that actually has any information.
Thank you! But i'm not quite sure where/how I should use this. I tried to use it as a transform script on the query, is that correct? It returns this error:
Unless your Table has bindings in place that are dependent on the DataSet structure of Table.props.data. If so, you should do something like this instead:
def transform(self, value, quality, timestamp):
# ALL columns of row must have value
# untested
max_rows = 3
original_pass = []
ds = system.dataset.toPyDataSet(value)
for row in ds:
if all(row.values()):
original_pass.append(row)
return original_pass[0:max_rows]
You shouldn't need the script transform anymore. Insert a return on line 2 to suppress it. If it turns out you don't need it then delete the whole transform later.