Resolving data from one store against another?

  • Hey guys,

    I'm having an issue that i can't seem to resolve (pun intended). Here is the situation:
    I have 3 data stores: users, machines, relations.
    This is the layout (i am listing the columns from the tables):
    users data store: id, username, password
    machines data store: id, name, version, location, ip
    relations: machine (id), user (id)

    so what this means is that the relations table maps what users have what machines. Continuing with the situation:
    I have created 3 grids, one contains the users, second the machines and last the relations.
    When we click on a user in it's respective grid, the relations grid is supposed to show the related machines. The i should be able to drag or remove machines, but lets not get ahead of ourselves.

    When i click on a user, i fire a call to filter the data in the relations grid on that user. This works to show only the particular machines for that user. Now i want to resolve the machine id's from that grid against the machines grid and display THAT data and not the relations table data.
    It keeps displaying the actual relations table data in the relations grid, and i have not been able to find a way to display data there from a different store. Does anyone have a better way of doing this? This is my first extjs project, so i'm sure that there must be a better way of doing this.

    Thanks,


  • Good solution, but it doesn't quite work for me. That mixes the relationships into the data itself. Here is the code i have been working with:

    <%inherit file="base.mako"/>
    <%def name="head_tags()">



    <%def name="body()">
    <% import time %>
    <% print time.time() %>




    When i click on a user in the user list the showmapping function gets invoked. I'm not asking for anyone to write my code, just to point me in the right direction. Am i using the stores correctly here? Maybe both the machines grid and the mapping grid should look at the machinesDS, while the relationsDS is not linked into a grid and used for logic manipulation? How would i filter one grid vs the other with a single store attached to both grids? If i have to use separate stores for each grid to do custom filters on each, then how can i reuse the data from the json call for both stores (instead of generating two json calls for the same data)?


  • Would it not be simple to have it like so


    users data store
    ----------------------
    user_id machine_id username password

    machines data store
    ----------------------
    machine_id name version location ip


    Then you could query all the data from user_store and pull in the extra data needed from the machine store as and when needed?

    Although i would prob create one data store that pulls in the main fields that we would need leaving you with one single data store like


    machine users data store
    --------------------------
    user_id machine_id username password machine_name machine_version machine_location machine_ip


  • I've been using a pattern like this:

    User records have a machine_ids field.
    Machine records have a user_ids field.

    When you load User and Machine data be sure that this data is interpreted as an Array. Look at Ext.dat.Record#create, specifically the 'convert' config option.

    First load Users and Machines, then do something akin to:

    userStore.each(function(user) {
    var machines = ;
    Ext.each(user.data.machine_ids, function(id) {
    machines.push(machineStore.getById(id));
    });
    user.set('machines', machines);
    });


  • "Maybe both the machines grid and the mapping grid should look at the machinesDS, while the relationsDS is not linked into a grid and used for logic manipulation?"

    That sounds like the right direction to me.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Resolving data from one store against another? , Please add it free.