Ben Bimber responded: |
2012-05-16 19:08 |
hi leo,
the Ext3 LabKey store doesnt provide a convenient public method to dynamically change the filter. as you found, there's a private method where you can set userFilters, which appears expect a similar array as the filterArray you can provide when you create the store. i havent tested this, but it looks like these will get re-applied each time the store loads. because this isnt part of the public API future stability is not guaranteed; however, i think this pattern should work:
var store = new LABKEY.ext.Store({....});
store.setUserFilters([LABKEY.Filter.create('myColumn', 'leo', LABKEY.Filter.TYPES.EQUAL)]); //use the same sort of filterArray as with the store itself
store.load(); //reload store so filters are applied |
|
Leo Dashevskiy responded: |
2012-05-17 11:38 |
Works rather well, thanks Ben (I was missing the (re)load call...) |
|
Leo Dashevskiy responded: |
2012-05-30 11:43 |
So what exactly happens to the store, if in the call
LABKEY.Filter.create(<columnName>, filesFilter.join(';'), LABKEY.Filter.Types.IN)
the filesFilter array is empty and hence the passed in string is "" ?
Thanks.
-Leo |
|
Leo Dashevskiy responded: |
2012-06-01 15:16 |
Not sure if my latest question in this thread "fell through the cracks" or not...
So I will attempt to answer it myself and you guys tell me, if it is right or not:
if an empty string '' is passed as a parameter into the creation of a Labkey filter object call with filter type IN, then such a filter filters out (somehow) all of the records in the store...
This is from my experience while dealing with it, I am not sure how/why it does that... |
|
Ben Bimber responded: |
2012-06-01 15:21 |
Hi Leo,
What I bet is happening is that this is getting interpreted as <columnName> IN (null). if none of your values are null, that would filter them all out. does this match what you see? |
|
Leo Dashevskiy responded: |
2012-06-04 11:27 |
Ok, Ben, that makes sense. Thanks. |
|
Leo Dashevskiy responded: |
2013-01-11 13:28 |
Hm, this question might be relevant all over again.
The approach recommended by Ben above does NOT seem to work anymore for 12.3, namely:
var strFilteredTable = new LABKEY.ext.Store({ sql: ... });
filterArrayToApply.push(
LABKEY.Filter.create(
<column name>,
<values separated by ;>,
LABKEY.Filter.Types.IN
)
);
strFilteredTable.setUserFilters(filterArrayToApply);
strFilteredTable.load();
the filters are set, but the store's data itself does not get filtered.
Please, help! |
|
Nick Kerr responded: |
2013-01-11 14:18 |
Hey Leo,
Seems to work for me. Have you touched the proxy or any other listeners on the store?
Also, just a minor thing it is 'LABKEY.Filter.Types.EQUAL' as you get an error with what you typed.
My repro:
var store = new LABKEY.ext.Store({ schemaName : 'core', queryName : 'users' });
store.load();
// see count after loaded using store.getCount()
store.setUserFilters([LABKEY.Filter.create('displayName', <your displayname>, LABKEY.Filter.Types.EQUAL)]);
store.load();
// now see count -- should be only the record(s) with that display name.
Thanks,
Nick |
|
Nick Kerr responded: |
2013-01-11 14:20 |
Also, check to see that the store is actually making the request to selectRows.view and see what the filter parameters are being used if it is being called. This should happen each time store.load() is called. |
|
Leo Dashevskiy responded: |
2013-01-11 15:26 |
Updated example that uses slashes for the query column names:
var strFilteredTable = new LABKEY.ext.Store({
autoLoad: true,
schemaName: 'flow',
sql: 'SELECT DISTINCT FCSFiles.Name AS "File/Name" FROM FCSFiles WHERE FCSFiles.Run.FCSFileCount != 0 AND FCSFiles.Run.ProtocolStep = \'Keywords\''
});
then try filtering on some file name values:
strFilteredTable.setUserFilters([LABKEY.Filter.create("File/Name", "file1.fcs;file2.fcs", LABKEY.Filter.Types.IN)])
strFilteredTable.load()
For the old server, it works, and for the new one it does not (as of 1/16, revision 24056)! |
|
Nick Kerr responded: |
2013-01-14 16:55 |
|
|
Leo Dashevskiy responded: |
2013-01-16 13:31 |
The "/" in the column name parameter in the LABKEY.Filter.create() call should not be used, it should instead by replaced by "$S". |
|