[Dojo-interest] how to use OR operator in fetching data from store

lukess mail2lokesh at gmail.com
Thu Aug 28 03:53:24 UTC 2008


Hi VSP,

  i have already tried that trick, but that didn't work. I am badluy stuck
into this problem.....

V S P wrote:
> 
> Even though I did not use reg expression in on fetch (I just use "*" ),
> I think your regular expression that you pass to the query is not
> correct
> your tempvnet ends up containing
> 
> val=3 | val=4 |val=5
> 
> 
> 
> What you want is 
> 3|4|5
> 
> you do not need the 'val' to be part of regular expression because it is
> alredy supposed
> to be a field name
> 
> So say your data store has a field called
> 'val'
> (or it can be called 'id'  -- but you have to name it explicitly)
> 
> and you want to fetch data based on the value in that field
> 
> var tempnet = 3 +  "|"  + 4 +  "|" +5;
> 
> 	yourStore.fetch({
> 			query:{val:tempnet},
> 			scope:this,
> 			onItem: function (itm)
> 			{
> 				console.debug("got item",itm);
>                         }
>                        });
> 
> Note I typically set scope attribute to 'this' -- so that the scope of
> the
> onItem function is the same as the scope where it is being called
> from...
> But it is not needed in many cases.
> 
> 
> and finally -- if the regular expression in tempnet is not
> enough to do the filtering you want, you can just 
> var tempnent="*"
> 
> and then onItem will get called for every element
> and in there you can decide to ignore some items programmatically.
> 
> I picked up a lot of info on the datastore stuff from the dojo
> definitive
> guide book -- saved me quite a few hours.
> 
> VSP
> 
> 
> On Wed, 27 Aug 2008 16:38:10 -0700 (PDT), "lukess"
> <mail2lokesh at gmail.com> said:
>> 
>> Hi,
>> 
>>   I want to fetch values from a datastore, depending upon some opertaion.
>> suppose i want to fetch all items where id ==1, id==2, id ==3; but i am
>> not
>> able to do that, and getting errors.
>> 
>> my code is something like:
>> 
>> var tempnet = "val=" +  3 +  " | val="  + 4 +  " |val=" +5;
>> var query = {
>> 		  
>>                     val: tempvnet;
>> 	};
>> 
>> Please let me know because i am stuck at this point.
>> 
>> Regards,
>> Lukes
>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/how-to-use-OR-operator-in-fetching-data-from-store-tp19191786p19191786.html
>> Sent from the Dojo mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at dojotoolkit.org
>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
> -- 
>   V S P
>   toreason at fastmail.fm
> 
> -- 
> http://www.fastmail.fm - A no graphics, no pop-ups email service
> 
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at dojotoolkit.org
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-use-OR-operator-in-fetching-data-from-store-tp19191786p19193794.html
Sent from the Dojo mailing list archive at Nabble.com.



More information about the Dojo-interest mailing list