Grid Panel ObjectDataSource with sub property

  1. #1

    Grid Panel ObjectDataSource with sub property

    hello,
    I am using the basic object datasource example to populate the EXT grid panel.

    my object I am using, contains basic properties.

    name
    description
    weapontypeID

    It also contains a sub property (since my object is from ADO.Net and displaying the available join)
    weapontype1.weapontype.name.

    When I use the datasource as a list of objects. the name, description, and weapontypeid work fine, but I can never get the 'sub property' within the internal object to display correctly.

    My code is below:

     <ext:GridPanel 
            ID="MarketPanel"
            runat="server" 
            Title="Market" 
            Height="600"
          
            >
            <Store>
                <ext:Store ID="Store1" runat="server"  >
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="name" />
                                <ext:ModelField Name="description" />
                                <ext:ModelField Name="weapontype" />
                                <ext:ModelField Name="weapontype.weapontype1.name" />
    
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" Text="Name" DataIndex="name"  />
                    <ext:Column runat="server" Text="Description" DataIndex="description" Flex="1"/>
                    <ext:Column runat="server" Text="Weapon TypeID " DataIndex="weapontype"/>
                    <ext:Column runat="server" Text="Weapon Type" DataIndex="weapontype.weapontype1.name />
    
                </Columns>            
            </ColumnModel>       
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Print" Icon="Printer" Handler="this.up('grid').print();" />
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:GridPanel>
      protected void Page_Load(object sender, EventArgs e)
            {
                BLL.BLL_Market BLLMarket = new BLL.BLL_Market();
          
                Store1.DataSource = BLLMarket.getAllWeapons();
              
            }
    How would I bind this correctly? I could wrap my object in a container, accessing these sub-properties on creation but I want to avoid that.

    many thanks.
  2. #2
    Hello,
    I have found the best way, and it was to basically use an anonymous type and re-declare my list, assigning the properties then applying to the datasource.

Similar Threads

  1. Replies: 6
    Last Post: Apr 23, 2013, 2:20 PM
  2. Replies: 17
    Last Post: Sep 27, 2012, 3:18 PM
  3. [CLOSED] how to set panel html property as javascript property
    By kenanhancer in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jan 05, 2011, 6:45 PM
  4. Replies: 2
    Last Post: Sep 29, 2010, 8:51 PM
  5. [CLOSED] Problem with grid panel property Reconfigure?
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 28, 2009, 10:45 AM

Tags for this Thread

Posting Permissions