简体   繁体   中英

How to get the item ID in vaadin

Good day everyone! I have a HierarchicalContainer below:

contFinalGrade= new HierarchicalContainer();
        contFinalGrade.addContainerProperty("index", Integer.class, 0);
        contFinalGrade.addContainerProperty("subCode", String.class, "");
        contFinalGrade.addContainerProperty("courseId", String.class, "");
        contFinalGrade.addContainerProperty("parentCourseId", String.class, "");
        contFinalGrade.addContainerProperty("subName", String.class, "");
        contFinalGrade.addContainerProperty("term", String.class, "");
        contFinalGrade.addContainerProperty("studyPoints", BigDecimal.class, null);
        contFinalGrade.addContainerProperty("grade", String.class, "");

and I add items by using the code below:

Item newItem = contFinalGrade.getItem(contFinalGrade.addItem());

I'm wondering how to get the itemId using parentCourseId. I need to get it because I need to set the parent of some items. Thanks!

Maybe this is what you are looking for:

List<Object> id = new ArrayList<Object>();

List<Item> newItem=new ArrayList<Item>();

//Do this on a button click or something maybe  
id.add(contFinalGrade.addItem()); 

//Create Items with those ids and get your property
for(int i=0;i<id.size();i++){
newItem.add(contFinalGrade.getItem(id.get(i)));

newItem.get(i).getItemProperty("parentCourseId");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM