about hierarchy table column

  1. #1

    about hierarchy table column

    I am right now working on creating a grid with hierarchy column. By saying hierarchy, I mean by default I will show contents in the first column and leave column 2 and 3 blank. Column one is my wildest category(e.g. nations), column two narrower category(e.g. states) and column three the narrowest(e.g. city). After clicking on one cell in column one, column two will show all states in that selected nation and column three will show all cities if any cell is selected in column 2.
    In which way I can achieve this? I've been looking through the demos and documentation and didn't find anything in grid panel that can do this. I don't think tree structure is the way to go, either.
    I appreciate your help. Thanks!
    Last edited by hy1990; Jun 19, 2014 at 7:00 PM.
  2. #2
    Hi @hy1990,

    Welcome to the Ext.NET forums!

    Probably, a TreeGrid is the way to go.
    http://examples1.ext.net/#/TreePanel/Advanced/TreeGrid/
  3. #3
    Hello @Daniil

    Thank you for your reply!
    I looked through the documentation and found Has-Many Association in 2.5 is exactly what I want. However I am running 1.X and can't use the association. Is there a similar way to achieve this?
    Here is my layout:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	47 
Size:	6.2 KB 
ID:	13051

    My goal is to choose a drug name and pops up different forms under that drug and pops up dosage under that form after choosing form.
    I am thinking organizing my data like this: list<drug name>contains list<form>, list<form> contains list<dosage>. However, I am having trouble putting this data into a store. Which kind of store or field should I use? And how can I achieve the popping up without using association?

    Thanks!

    Addition:
    I figured using a dictionary to organizing my data is easier. Here goes: dictionary 1 contains drug name and form dictionary2, dictionary 2 contains form name and dosage dictionary3. Can I bind this data to store? If so, how can I do it?
    Last edited by hy1990; Jun 25, 2014 at 2:48 PM.
  4. #4
    There are no Associations in Ext.NET v1.x, but you can put any data into a Store, for example, an array of entities. Please look at
    <ext:RecordField Name="Customers" IsComplex="true" />
    in this example:
    http://examples1.ext.net/#/DataView/Advanced/Report/

    The IsComplex="true" setting means that you bind some non-primitive data to a RecordField. This data will be fully serialized.
  5. #5
    I guess I will attach my code behind.
    List<DataRow> drug = dt.AsEnumerable().ToList();
    Dictionary<string, Dictionary<string, Dictionary<string, DataRow>>> drugtree = new Dictionary<string, Dictionary<string, Dictionary<string, DataRow>>>();
    
                //*************************************start grouping values*******************************************
                foreach (DataRow dg in drug)
                {
                    string DN = dg["BN"].ToString();
                    string form = dg["TitleName"].ToString();
                    string dos = dg["strength"].ToString();
                    //List<string> res = drugName.Find(DN);
                    Dictionary<string, Dictionary<string, DataRow>> temp;
                    if (drugtree.TryGetValue(DN, out temp))
                    {
                        Dictionary<string, DataRow> temp2;
                        if (temp.TryGetValue(form, out temp2))
                        {
                            DataRow temp3;
                            if (!temp2.TryGetValue(dos, out temp3))
                            {
                                //add drug
                                temp2.Add(dos, dg);
                            }
                        }
                        else
                        {
                            //add drug
                            Dictionary<string, DataRow> ele = new Dictionary<string, DataRow>();
                            ele.Add(dos, dg);
                            temp.Add(form, ele);
                        }
                    }
                    else
                    {
                        //add drug
    
                        Dictionary<string, DataRow> ele = new Dictionary<string, DataRow>();
                        ele.Add(dos, dg);
                        Dictionary<string, Dictionary<string, DataRow>> ele2 = new Dictionary<string, Dictionary<string, DataRow>>();
                        ele2.Add(form, ele);
                        drugtree.Add(DN, ele2);
                    }
                }
                this.Store1.DataSource = new object[]{"Name 1",drugtree};
                this.Store1.DataBind();
    Here is what I did to create dictionary inside dictionary inside dictionary to group my data.
    When I was writing store, I tried this.
     <ext:Store ID="Store1" runat="server" IgnoreExtraFields="false" AutoLoad="true"
            RemoteSort="true" groupfield ="BN">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="BN" />
                        <ext:RecordField Name="strength" Type="String" />
                        <ext:RecordField Name="TitleName" Type="String" />
    
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>
    I guess this won't work because there is no way for reader to tell which key for dictionary is BN, strength and Title. So I am stuck here to create a reader and recordfield. Any idea how to write the store?
  6. #6
    Well, there are two ways. Either you modify/prepare the data on server, or serialized everything to client and retrieve everything that you need on client. With the second way, as I mentioned, you will probably need to use IsComplex="true" and, probably, a RecordField's Convert.

    There is a sample of a RecordField's Convert handler.
    http://examples1.ext.net/#/GridPanel.../Data_Prepare/

Similar Threads

  1. [CLOSED] Column layout to build a table dynamically
    By trePjt in forum 2.x Premium Help
    Replies: 4
    Last Post: Dec 10, 2013, 6:15 AM
  2. Replies: 1
    Last Post: Nov 12, 2012, 1:54 PM
  3. Replies: 3
    Last Post: Aug 29, 2011, 6:26 AM
  4. [CLOSED] Table Layout, 100% width Table
    By sisa in forum 1.x Premium Help
    Replies: 5
    Last Post: May 20, 2011, 6:40 AM
  5. [CLOSED] Dynamically changing control hierarchy
    By randy85253 in forum 1.x Premium Help
    Replies: 6
    Last Post: Dec 13, 2009, 4:57 PM

Tags for this Thread

Posting Permissions