filter functions problem - apache-flex

I'm working on a search component for an app I'm working on and I needed to add some filters to it. I've found an example and got the first filter working fine.
Now I'm trying to add a second filter I'm running into problems... In the example I found they use filterFunctions, but I only get an option for filterFunction, why is that?
Here's the example code
productsCollection.filterFunctions =
[
filterByPrice, filterByType,
filterByCondition, filterByVendor
]
And this is what I'm trying
acData.filterFunction = [filterByStatus, filterByDate]
but with this code I get the following error message - 1067: Implicit coercion of a value of type Array to an unrelated type Function.
Why am I getting this error and how would I go about add multiple filters to my Array Collection?
Thanks!

filterFunction must be set to a single function, not an Array or any other datatype. To combine multiple functions create one that combines them, like this:
acData.filterFunction = function(item:Object)
{
return
filterByPrice(item) &&
filterByType(item) &&
filterByCondition(item) &&
filterByVendor(item);
};
If you saw a sample that used filterFunctions plural that accepted an array, post a link. That's not anywhere in the standard Flex framework or in the new 4.0 beta afaik.

It looks like you are going to have to extend an arraycollection to make it work. this link should spell it out for you: http://blog.rotundu.eu/flex/arraycollection-with-multiple-filter-functions/

Related

add some custom information to node drupal 8

I need to update my referential entity with new values ​​that are inserted every time a user visits the page. I tried to use this code but unfortunately, the latter does not add a value but replaces all of them. I am attaching the code that I used in the hope that someone can help me with this problem. thank you
nodeObj = Node::load(implode($nids));
$nodeObj->set('my_field', $current_user_id);
$nodeObj->save();
If I understand your issue correctly, your code is overwriting the entire value of my_field rather than appending a new value. Also, the implode() and the $nids variable suggest to me that you may be trying to perform this function on multiple nodes at once, which your current code will not do.
Make sure my_field is an ItemList field of some kind.
Try this code:
$nodeObjs = Node::loadMultiple($nids);
foreach ($nodeObjs as $nodeObj) {
$nodeObj->my_field->appendItem($current_user_id);
$nodeObj->save();
}

Testing for WordPress custom post type variables

Within the array for a custom post type named rg_story that I am defining, I have the following statement:
'chronological' => true,
Later, I have this:
if ( 'rg_story' == get_post_type()) {
As far as I know, everything is working OK. I'll know for sure once I create my templates. This is my first time with this stuff.
The problem is that I would like to test for the value of 'chronological', rather than the specific post type. I'm just not sure which function would do that.

Sonata Admin Bundle Search: NonUniqueResultException as Result

When I try to use the search-function in the Sonata Admin Bundle I always get:
An exception has been thrown during the rendering of a template ("The
query returned a row containing multiple columns. Change the query or
use a different result function like getScalarResult().") in
SonataAdminBundle:Core:search.html.twig at line 53.
NonUniqueResultException: The query returned a row containing multiple
columns. Change the query or use a different result function like
getScalarResult().
When I do the search in the productive environment I just get a result if the Admin-Class has no result:
e.g. for Countries (CountryAdmin Class): no result found
I am using sonata-project/admin-bundle (2.3.10)
I tried to reduce my admin-classes to a single one which is very basic - but still having this problems. Any ideas? Thanks...
I had problem with getScalarResult() method, when i did groupBy into my Admin class in createQuery() method.
Maybe it will help
https://groups.google.com/forum/#!topic/sonata-users/cBT09egDtuo
https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/297

In tensorflow, can you define your own collection name?

I searched all resources in tensorflow's API documents and can't find any indication.
It seems when using get_variable(), I can put a specific name for collections term like:
x=tf.get_variable('x',[2,2],collections='my_scope')
but get only empty list when doing:
tf.get_collection('my_scope')
collectionS needs a list of collection name.
>>x = tf.get_variable('x',[2,2], collections=['my_scope'])
>>tf.get_collection('my_scope')
[<tensorflow.python.ops.variables.Variable at 0x10d8e1590>]
watch out that if you use it some other operations can have side effects.
like tf.all_variables() will not work and thus tf.initialize_all_variables() also will not see your variable. One way to fix it is to specify the default collection too.
>>x = tf.get_variable('x',[2,2], collections=['my_scope', tf.GraphKeys.VARIABLES])
but things starts to get tedious.
Actually, you can use tf.get_collection to create a new collection:
tf.get_collection('my_collection')
var = tf.get_variable('var', [2, 2], initializer=tf.constant_initializer())
tf.add_to_collection('my_collection', var)

Symfony2 passed argument is null

I'm building a CRM system and I faced a weird problem I'm unable to solve. When I try to create a new CustomerCase entity, I want to assign a CaseState entity for it, so this is what I do in the createAction of CustomerCaseController.php:
$caseStateId = $request->request->get('caseState_id');
$caseState = $this->getDoctrine()->getManager()->getRepository('HSWAshaBundle:CaseState')->findOneById($caseStateId);
$entity = new CustomerCase();
$entity->setCaseState($caseState);
...... etc.....
Everything works just fine until the setCaseState method. After running setCaseState, I get the following error:
Catchable Fatal Error: Argument 1 passed to HSW\AshaBundle\Entity\CustomerCase::setCaseState() must be an instance of HSW\AshaBundle\Entity\CaseState, null given, called in /home/webuser/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 538 and defined in /home/webuser/Symfony/src/HSW/AshaBundle/Entity/CustomerCase.php line 843
The weird part is that $caseState really is a CaseState object (because for example $caseState->getName() works and gives me the correct name for the selected CaseState). For some mind blowing reason it just turns null when I use the setCaseState method. If I do $entity->setCaseState($customerStateObject->getId()), I get the same error message, but this time null changes to integer.
The CustomerCase has a manyToOne relationship with CaseState.
This works just fine if I use the formBuilder's add() method and skip all this manual work, but since I'm using a very specific auto-populating jQuery dropdown for selecting the CaseState from a nested tree structure, I had to manually add the dropdown and read it with $request->request->get().
I've been fighting with this part for almost three days now and would greatly appreciate every help I can get with this!
Finally I got it to work! The reason was $request was missing some parameters because the twig template was missing form_rest(form). After adding that, everything started to work. Thank you!

Resources