473,385 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I make two DOJO QueryReadStores depend on eachothers data?

29
Hi!

Background info

What I have is the classic zip code - city relation.
They are fed into two QueryReadStores. Each Store back an individual filteringselect box.

The datastores are fed from a Spring Controller with one method for each store. Each method returns json data containing either zip codes or city names.

Each time a filteringselect box recieves an input, the method in the spring controller attached to the backing store is run and returns the options available depending on the input in the filteringselect.

The JSON structure is really simple for both stores it looks like this:

Expand|Select|Wrap|Line Numbers
  1. {label:zip,
  2. items:[ {zip: 12345},{zip:12346}, ... ] }
  3.  
  4. {label:city,
  5. items:[ {city: NEW YORK},{city:CHICAGO}, ... ] }
  6.  
  7.  
  8.  
In the backend a zipcode is mapped to a city.

I have the individual filteringselects working perfectly through this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <label for="postnr">Zip:</label>
  3. <input id="postnr">
  4.  
  5. <label for="postort">City:</label>
  6. <input id="postort">
  7.  
  8. <script type="text/javascript" src="dojo/dojo.js"
  9.         djConfig="isDebug: true, parseOnLoad: true"></script>
  10. <script type="text/javascript">
  11. dojo.require("dijit.form.FilteringSelect");
  12. dojo.require("dojo.data.ItemFileReadStore");
  13. dojo.require("dojox.data.QueryReadStore");
  14.  
  15.     dojo.addOnLoad(function() {
  16.  
  17.  var postnrstore = new dojox.data.QueryReadStore({url: "postnr.json"});
  18.         postnrstore.fetch({serverQuery:{name:''}, queryOptions:{ignoreCase:true}});
  19.  
  20.         new dijit.form.FilteringSelect({
  21.             store: postnrstore,
  22.             searchAttr: "zip",
  23.             style: "width: 100px;",
  24.             id: "postnr",
  25.             },"postnr");
  26.  
  27.         var postortstore = new dojox.data.QueryReadStore({url: "postort.json"});
  28.         postortstore.fetch({serverQuery:{name:''}, queryOptions:{ignoreCase:true}});
  29.  
  30.         new dijit.form.FilteringSelect({
  31.             store: postortstore,
  32.             searchAttr: "city",
  33.             style: "width: 200px;",
  34.             id: "postort",
  35.             },"postort");
  36.     });
  37.  
  38. </script>
  39.  

Problem
How do I go about linking the two filteringselects so that they affect the other store depending on its own input.

That is if I have typed zip: 123 and the mapped cities for a zip starting with 123 are Chicago, New York and Washington DC. How do I get the city filteringselect to only display those three options?

And also the other way around, how do I display the zipcodes available for Washington DC if that is my input in the city filteringselect


Should I expand the structure of the JSON code to include the relations, or can it be done with the current structure?

best regards
rythmic
Mar 18 '10 #1
1 2928
acoder
16,027 Expert Mod 8TB
I've not really worked with Dojo, so I wouldn't know if there's a built-in or a more efficient method (save checking the docs), but can you not pass something to the script that returns the filtered options to update it when a change is made in either the zip code or the city.
Mar 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Bailo | last post by:
I'm looking for an api reference or more detailed examples for the use of the dojo chart widget. I've set up the example code, and can see roughly how I can manipulate it vi HTML. I am...
5
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of...
15
by: plsHelpMe | last post by:
Hi All, I am having a problem. I am using DOJO toolkits to fetch some data on my webpage. Now suppose if i leave my webpage for some time and the session gets expired and then i try to click on...
3
by: ygjyothi | last post by:
Hi All, I'm trying to integrate Ext2.0 and Dojo 1.0 i.e the selected rows from a Ext 2.0 Grid upon a button click should generate a Dojo 1.0 Chart in a pop up window or Ext.window.There is a Ext...
7
by: raknin | last post by:
Hi, Hi, Now that I am handle the way of use the dojo combobox I moving to the next stage. What I want to do is updating a second combobox automatically when a value is selected in the first...
5
by: gaya3 | last post by:
Hi, can anyone find error in the following example <%@ include file="JspBean.jsp" %> <%@ page import="java.util.*"%> <html> <head> <%
2
by: pincopallo_it | last post by:
I started using dojo for my AJAX application . i need really a selectbox which read a json file and that with the onchange() modify a second select box. I tried using the filtering select of dojo...
1
by: kokababu | last post by:
I am trying to load dojo module from different domain; such as dojo.parser, dijit.form.TextBox etc. <html> <head> <script type="text/javascript"> djConfig = { isDebug: true,...
1
by: ashutoshjoshi10 | last post by:
Hi, I am using a Dijit.form.filteringSelect to display values using the dojox.data.QueryReadStore. But, after overriding _filterResponse() to format the data in a Dojo-parsable format, whatever...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.