[CLOSED] V2.0 question on Model Associations and HasManyAssociation

  1. #1

    [CLOSED] V2.0 question on Model Associations and HasManyAssociation

    Hi, could you help me to be explained on the command or property (?) and a small example of how you can use it to manage relationships :

     <Associations>
                      <ext:HasManyAssociation  ... ??/>
                    </Associations>
    I read something in the documentation for extjs, but I can not understand how it works.

    I have two table, "Clients" & "Orders", it's possible load a gridpanel with clients ad the click on a row load the order of client use the "Association" without performing a second query to load the orders ?

    Thanks for any response

    Aurelio
    Last edited by geoffrey.mcgill; Apr 13, 2012 at 12:10 AM. Reason: [CLOSED]
  2. #2
    Hi,

    We are working on the examples. Today-tomorrow they should appear in SVN. We will notice you.
  3. #3
    Hi Daniil...
    Ok ...thank you very much

    Aurelio
  4. #4
    Vladimir has committed the changes.

    Please update Ext.NET.

    The examples are in Examples.Ext.NET, it's on GitHub:
    https://github.com/extnet
  5. #5
    Hi, Daniil
    Thanks,tomorrow download the sample and test.

    Aurelio
  6. #6
    Hi, thanks for the sample. I tried to make an example but I can not make it work, could you help me?
    I have two Table Parent (Table PROVINCE) & Child (Table CAPCOM), i load the Store whit this linq query:

    var database = new DataClassesARWebRevolutionDataContext();
                Store1.DataSource = database.PROVINCE.Where(row => row.ProId < 3).Select(row => new
                                                                                                    {
                                                                                                        comuni = row.CAPCOM.ToList(),
                                                                                                        row.ProId,
                                                                                                        row.ProDes
                                                                                                    });
    The Store after the query content this data:
    Click image for larger version. 

Name:	Immagine.png 
Views:	64 
Size:	27.8 KB 
ID:	4078

    I have define the grid :

             <ext:GridPanel ID="GridPanel1" 
                    runat="server" 
                    Title="Province (seleziona una provincia per vedere i suoi comuni)" 
                    Flex="1">
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                            <Model>
                                <ext:Model ID="Model1" runat="server" Name="Province" IDProperty="ProId">
                                    <Fields>
                                        <ext:ModelField Name="ProId" Type="Int" />
                                        <ext:ModelField Name="ProDes" Type="String" />                                                                  
                                    </Fields>        
                                    <Associations>
                                        <ext:HasManyAssociation Model="Com" AssociationKey="comuni" Name="test" />
                                    </Associations>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:Column ID="Column1" runat="server" Text="Provincia" DataIndex="ProDes" Flex="1" />
                        </Columns>            
                    </ColumnModel>       
                    <Listeners>
                        <SelectionChange Handler="selected.length && #{ProductsGrid}.bindStore(selected[0].test());" />
                    </Listeners>                
                </ext:GridPanel>
                <ext:GridPanel 
                    ID="ProductsGrid"
                    runat="server" 
                    Title="Products" 
                    Flex="1">
                    <Store>
                        <ext:Store runat="server">
                            <Model>
                                <ext:Model runat="server" Name="Com" IDProperty="CapComId">
                                    <Fields>
                                        <ext:ModelField Name="CapComId" Type="Int" />
                                        <ext:ModelField Name="CapComCom" Type="String" />
                                    </Fields>        
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:Column ID="Column2" runat="server" Text="Comune" DataIndex="CapComCom" Flex="1" />
                        </Columns>            
                    </ColumnModel>                            
                </ext:GridPanel>
    The GridPanel1 is load correctly, but the click on a row the 2 gridpanel not load the data.
    I can not understand the problem..the store1 i think it is loaded correctly.

    Thanks
    Aurelio
  7. #7
    Hi,

    Do you have 'comuni' property in theserialized data?
    Please show serialized data for Model1 (Province)?

    AssociationKey="comuni" assumes that serialized data for Model1 has array property contains list of records for Com model
  8. #8
    Hi, Vladimir

    I have no idea how to do serialized the data, we have to study ..
    Now I see how to serialize the data..

    Thanks
  9. #9
    Hi,

    Please note that in the example Ext.Net.Examples\Examples\Associations\HasMany\Sim ple\Default.aspx (i guess that you investigated that sample)
    we use Data property of a store, the difference between Data and DataSource that Data object is serialized completely (all properties) but DataSource object is serialized according defined model fields

    Our class User has Products property and that property is serialized (even if it is not defined in fields) therefore we can use AssociationKey="Products"
  10. #10
    Hi Vlidimir
    Thanks, I look for how to serialize the result of a linq query, I think there is a way, I go to san google :)

    Aurelio

Similar Threads

  1. [CLOSED] How to get the value for the IdProperty in a Model
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 03, 2012, 2:10 PM
  2. Question about Checkbox Selection Model in GridPanel
    By slonati_adv in forum 2.x Help
    Replies: 0
    Last Post: Jul 12, 2012, 2:19 PM
  3. [CLOSED] Question about Selection Model in GridPanel
    By rosua in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 04, 2012, 11:29 AM
  4. [CLOSED] EXT.NET and ASP.NET MVC View Model
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 18, 2011, 6:04 PM
  5. [CLOSED] Can SelectionModel have two model
    By pank in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 02, 2009, 9:13 AM

Tags for this Thread

Posting Permissions