0

grouping inside group of listbox in zk

asked 2014-09-28 12:46:27 +0800

shraddhadixit89 gravatar image shraddhadixit89
1 1

updated 2014-09-29 09:50:10 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

I am using listbox and grouping some listItems. Problem I am facing is I have grouped my items using GroupsModelArray class but i again want to group inside group. say for eg here i have grouped by birth now I want to again group inside birth by regular & optional. can anyone suggest me something? for example: i have list of vaccines i have grouped them by birth/6 weeks/12 weeks etc now inside birth i want to group them by regular/optional. code:

 GroupsModelArray groupModel = new GroupsModelArray(listValue, new RowLabelComparator("null",true));                elementObj.setModel(groupModel);
                    if(elementObj instanceof Listbox)
                    {
                        ItemRendererArray itemRenderer = new ItemRendererArray();
                        if(gridDef != null)
                        {
                            itemRenderer.setGridDef(gridDef);
                        }               
                        elementObj.setItemRenderer(itemRenderer);
                    }
                    else 
                    {
                        elementObj.setRowRenderer(new GridRowCustomRenderer());
                    }

    public class RowLabelComparator extends FieldComparator 
    {
        public RowLabelComparator(String orderBy, boolean asc) 
        { 
            super(orderBy, asc); 
        }
        public int compare(Object o1, Object o2) 
        {
            Object[] listValue1 = (Object[])o1;
            Object[] listValue2 = (Object[])o2;
            System.out.println("listValue length="+listValue1.length);
            int objectCounter =0;
            Object retValue = null;
            String[][] dummyValues = new String[listValue1.length][];
            int lengthOfList = listValue1.length;
            int dueIndex = 0;
            int regularOptionalIndex = 1;

            Object obj1 = listValue1[dueIndex];
            Object obj2 = listValue2[dueIndex];

            Object objVaccineType1 = listValue1[regularOptionalIndex];
            Object objVaccineType2 = listValue2[regularOptionalIndex];

            if(obj1!= null && !obj1.getClass().isArray())
            {
                if(obj!=null)
                {
                    String str1 = obj1.toString();
                    String str2 = obj2.toString();
                    int valueOf1 = 0;
                    str1 = str1.trim();
                    if(str1.equals(str2))
                    {
                        if(objVaccineType1.equals(objVaccineType2) && objVaccineType1.equalsIgnoreCase("regular"))
                        {
                            valueOf1 = 0;                       
                        }
                        else if(objVaccineType1.equals(objVaccineType2) && objVaccineType1.equalsIgnoreCase("optional"))
                        {
                            valueOf1 = 0;                       
                        }                   
                    }
                    else if(str1.equals("Birth"))
                    {
                        valueOf1 = 2;
                    }
                    else if(str1.equals("6 Weeks"))
                    {
                        valueOf1 = 3;
                    }                   
                    else if(str1.equals("10 Weeks"))
                    {
                        valueOf1 = 4;
                    }   
                    else if(str1.equals("14 Weeks"))
                    {
                        valueOf1 = 5;
                    }   
                    else if(str1.equals("18 Weeks"))
                    {
                        valueOf1 = 6;
                    }
                    else if(str1.equals("22 Weeks"))
                    {
                        valueOf1 = 7;
                    }
                    else if(str1.equals("6 Months"))
                    {
                        valueOf1 = 8;
                    }
                    else if(str1.equals("9 Months"))
                    {
                        valueOf1 = 9;
                    }
                    else if(str1.equals("1 Year"))
                    {
                        valueOf1 = 10;
                    }                   
                    else if(str1.equals("15 Months"))
                    {
                        valueOf1 = 11;
                    }
                    else if(str1.equals("18 Months"))
                    {
                        valueOf1 = 12;
                    }
                    else if(str1.equals("2 Years"))
                    {
                        valueOf1 = 13;
                    }
                    else if(str1.equals("5 Years"))
                    {
                        valueOf1 = 14;
                    }                   
                    System.out.println("str1="+str1);
                    System.out.println("str2="+str2);                   
                    return valueOf1;
                }           
            }
            return -1; 
        }
    }
delete flag offensive retag edit

Comments

Which ZK version you are using? and why you are using MVC design pattern while this can be achieve in MVVM very easily

sjoshi ( 2014-09-29 09:51:43 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-09-28 12:46:27 +0800

Seen: 11 times

Last updated: Sep 29 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More