-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
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?
2 | No.2 Revision |
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)); // null in argument is not in use, its just to initialize constructor.
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;
}
}
3 | No.3 Revision |
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.
}
4 | edited code tag |
GroupsModelArray groupModel = new GroupsModelArray(listValue, new RowLabelComparator("null",true));