1

App Maker > Page > Table > Events > onAttach

works:

var datasource = widget.datasource;
datasource.query.filters.readByUsers._contains = 'Susanne';
datasource.load();

doesn't work:

var datasource = widget.datasource;
datasource.query.filters.readByUsers._notContains = 'Susanne';
datasource.load();

Any filter with _equals works too.

Can anyone say why? Or maybe the even better question is: How do you set filtered table views in app maker?

Again: How do you exactly set filters for your tables?

  • Welcome to SO! please read [mcve] and edit your question accordingly and follow the same in future. please add what you trying to do? what is expected output? what is actually happening? what are error stack trace etc.. – Dev Nov 30 '19 at 21:11

2 Answers2

0

According to the official documentation:

Filters startsWith, notStartsWith, contains, notContains are only supported for strings.

Therefore, if your field is a string field, it should definitely work. However, the only reason I can think this will not work, is if you are applying a filter on top of another filter without clearing the previous filter first. I.e., If you run the following code:

var datasource = widget.datasource;
datasource.query.filters.readByUsers._contains = 'Susanne';
datasource.load();

It will only return results where the field readyByUsers contains the string Sussane. If after that you run the code:

var datasource = widget.datasource;
datasource.query.filters.readByUsers._notContains = 'Susanne';
datasource.load();

It will return zero results because all the records loaded contain the string Susanne. Hence it might give you that effect that it is not working when indeed is.

To make sure that your filters work properly, you first need to clear the previous filter before applying a new one, unless you explicitly want to apply a second filter on top of the first one. For that, you need to run the clearFilters method. So your code should look like this:

var datasource = widget.datasource;
datasource.query.clearFilters();
datasource.query.filters.readByUsers._contains = 'Susanne';
datasource.load();

Or like this:

var datasource = widget.datasource;
datasource.query.clearFilters();
datasource.query.filters.readByUsers._notContains = 'Susanne';
datasource.load();
Morfinismo
  • 4,985
  • 4
  • 19
  • 36
  • @ThomasJaud in that case I recommend you to expand your question details because at this moment, you are doing something very wrong and not providing sufficient details to help you. – Morfinismo Dec 01 '19 at 14:19
  • Hi thanks for the help, I`m very new with stackoverflow and google app maker. Can you tell me which infos you need to help me further? – Thomas Jaud Dec 02 '19 at 10:38
0

the correct answer was:

because the field was "null"

so you need to add the filter "_notEquals = null;" to get results