Table selection, filters problem and bugs

Hello guys
I have a problem with calculation the total of a filtered column.
When I write something in the filter (search bar) of the table
the results are out and I can have an amount.
If I also apply a column filter after that, everything is ok.
But if I apply only a column filter without typing in the search bar, the selected data does not appear anywhere.
The filtered rows appear visually, but not the data

I have a change script in a filter.data-> self.refreshBinding("props.columns[2].footer.title")

There are another bugs:

  1. When I use preview mode in designer, the text in the search bar appears in the client sessions and the client table gets messed up.

  2. Same with the dropdown when I select something in designer preview mode in the dropdown that appears in client sessions and it stays if I don't delete it from the designer.

  3. If I have a applied column filter in one session it appears in a others sessions.

I don't use any associated tags, everythings is 'self.props'




I don't understand the problem, can you try describing the issue in french ?

As for the script, I'll suggest this:

def transform(self, value, quality, timestamp):
	val = self.props.filter.results.data
	if not val:
		val = self.props.data
	q = sum(v['poids'] for v in val)
	return "Total: {} Kg".format(round(q, 3))

It should do the same thing, but I didn't try it so there might be typos/syntax errors.

the problem is not in the script.
yours do the same job.

When I write something in the filter (search bar) of the table
the results are out and I can have an amount from 'self.props.filter.results.data'
If I also apply a column filter (see pic.1) after that 'self.props.filter.results.data' updates and result is ok.

But if I apply only a column filter without typing in the search bar, the selected data does not appear anywhere.
The filtered rows appear visually, but not the data changed in a 'self.props.filter.results.data'

Column filters are relatively new, they might still be a bit buggy.
Either wait for more advice on this, or contact support.

I know, I did say "It should do the same thing".
It's just cleaner and more efficient.

'It's just cleaner and more efficient.'

Тhanks, that's not the topic.
Tell about other bugs, pls.

If you're going to take it like this, no thanks and good luck.

Bye master.

I rework and optimize the code before releasing the project, this is the final stage.
Before that, I write without thinking maybe 10 times different code in the fastest way possible for me.
Be helpful, not talkative, this is not a Python course.

Hello Sir.
I have a similar problem.
I'm trying to sum the values of a column and put the result at the bottom in the footer.
I tried to use your code, I don't know Python well (I'm from .NET)...
my goal (if possible), is to update the total of the 'Quantity' column in the footer in "real time" (as I type in the table filter).
This is what I've done so far...
Thank you in advance if you have any suggestions.


script

I think you should ask a new question. @pascal.fragnoud dropped out of this one due to the rudeness of the OP. (Pascal is one of the really helpful users on the site and has made about 2,200 posts.) He is unlikely to respond on this thread so delete your post here and ask a new one.

I don’t mind answering to polite people, wherever it is.
@eMax I’m on a phone right now so it’s not an ideal situation to give you pointers, I’ll try and remember to come back to this when I have a designer available.
I’m the meantime, just to make things extra clear: you want to update the footer in real time with the sum of the values in the column, using only the values that were not filtered out. It’s that correct ?

2 Likes

yes, that's correct
@Transistor, you were right, I had to ask a new question.
This is my first question ever on this forum.
I wrote directly to mr. Fragnoud because I've seen this "problem" is quite similar to mine

Alright, so the setup I used first:

  • prop.filter enabled
  • prop.filter.results enabled
  • footer enabled
  • explicitly defined columns in the columns prop
  • property binding on the "quantita" column's footer.title, bound to props.filter.results.data
  • script transform on this binding with this code:
data = value if value else self.props.data
s = sum(v['population'] for v in data)
return "total: {}".format(s)

BUT !
This works for tables with json formatted data.
It seems your table is using a dataset, which is not iterable in the same way, and that's why the script fails. Since it fails, it returns null, and this leads to the second error as the title property of the footer expects a string.

For datasets, you can use this transform instead:

if value:
    total = sum(v['quantita'] for v in value)
else:
    col_index = self.props.data.getColumnIndex("quantita")
    total = sum(self.props.data.getColumnAsList(col_index))
return "total: {} Kg".format(round(total, 0))
1 Like

wow, that's great!
it works almost as expected.
By the way, in this case, json works better than dataset.
The only "bug" is that the total at first (when page opens) shows "0" and total is not populated until I write something in the filter.
You put me on the right path!
Thanks a lot!

Right, an oversight on my part.
To fix this, use a structure binding instead of a property binding, in which you'll create 2 elements, one bound to props.data and the other one to props.filter.results.data.
Then use those values in the transform:

script for datasets:

if value.filtered:
    total = sum(v['qty'] for v in value.filtered)
else:
    col_index = value.data.getColumnIndex("qty")
    total = sum(value.data.getColumnAsList(col_index))
return "total: {} Kg".format(round(total, 0))

for json:

data = value.filtered if value.filtered else value.data
total = round(sum(v['population'] for v in data), 0)
return "total: {}".format(total)

Thank you @pascal.fragnoud!
Everything works fine, you saved my day.

Have a nice evening.