0

Dynamic groupbox Issue.

asked 2016-01-06 13:12:28 +0800

sathishk gravatar image sathishk
17 5

updated 2016-01-07 12:48:12 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

Hi,

We are developing dynamic groupbox by using model list, we have getting groupbox header multiple,but when i click on groupbox,then show all groupbox values : please go through below code :

<div children="@load(vm.expensesforApprovalProcess)" >
 <template name="children" var="each">
     <groupbox width="100%" mold="3d" closable="false" open="true">
         <caption sclass="caption_new" onClick="@command('showApprovalRequestDetails',requestID = each.processID)">
             <div class="col-md-6 col-sm-6 padd0">
                 <div class="form-horizontal mrg_top10">
                     <div class="form-group marg0">
                         <h:label class="col-md-3 col-sm-4 col-xs-4 padd_l0">Date of Expense </h:label>
                         <div class="col-md-9 col-sm-8 col-xs-8">
                             <label class="padd0" value="@load(each.createdDate)"></label>
                         </div>
                     </div>
                     <div class="form-group marg0">
                         <h:label class="col-md-3 col-sm-4 col-xs-4 padd_l0">View voucher: </h:label>
                         <div class="col-md-9 col-sm-8 col-xs-8">
                             <a href="">
                                 <image src="../css/images/view_attachment.png" onClick="@command('ExpanseReport',expense = each)" visible="@bind(each.isshowVoucher)"/>
                             </a>
                         </div>
                     </div>
                 </div> 
             </div>
         </caption>
         <div class="form-horizontal master_group master_group_first mrg_top10" children="@load(vm.expensesforApproval)" >
             <template name="children" var="each">
                 <div class="form-group col-md-4">
                     <h:label class="col-md-6 col-xs-6">Employee Code </h:label>
                     <div class="col-md-6 col-xs-6">
                         <label value="@load(each.edp_no)"></label>
                     </div>
                 </div>
                 <div class="form-group col-md-4">
                     <h:label class="col-md-6 col-xs-6">Employee Name: </h:label>
                     <div class="col-md-6 col-xs-6">
                         <label value="@load(each.empName)"></label>
                     </div>
                 </div>

                 <div class="form-group col-md-4">
                     <h:label class="col-md-6 col-xs-6">Status: </h:label>
                     <div class="col-md-6 col-xs-6">
                         <label value="@bind(each.status)"></label>
                     </div>
                 </div>
                 <div class="clearboth"></div>
             </template>
         </div>
         <div class="clearboth"></div>
     </groupbox>
 </template>

Please Help me!.

delete flag offensive retag edit

Comments

Hello sathishk. Could you give some more information regarding your issue?

Darksu ( 2016-01-07 11:38:39 +0800 )edit

Dear Darksu , we have using dynamic groupbox,suppose we have two groupbox having multiple records,when i click on one groupbox then open clicked groupbox withed records,but when i click on particular groupbox shows all groupbox information,kindly check above code.

sathishk ( 2016-01-07 12:05:16 +0800 )edit

your var in the 2 template are called each, but they nest each other. Please use unique keywords in a scope.

chillworld ( 2016-01-07 12:52:02 +0800 )edit

Dear chillworld,thank you for respnse.we have added different var declaration;first temple given as var=each and next one as var=each1.But same issue showing.

sathishk ( 2016-01-07 16:04:36 +0800 )edit

I can't follow it completely, is it possible to recreate the issue in zk fiddle or post some screenshots with the issue? (Personally I prefer a zk fiddle)

chillworld ( 2016-01-07 19:15:10 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-01-08 07:31:27 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2016-01-11 06:49:59 +0800

I think I have found your problem.

First you iterate over a collection to show multiple groupboxes.
Secondly you make a template in each groupbox for the values of the groupbox :

children="@load(vm.expensesforApproval)"

But this collection is the same for every groupbox. You need to make a separation for it and it's possible by :

children="@load(vm.getExpensesforApproval(each.processID))"

so the getter is now :

public ListModel getExpensesforApproval(Integer id) {
    return new ListModelList(filterCollectionOnId(id));
}

Edit:

In the zul, add this to the groupbox :

onOpen="@command('open')"

and the java code :

@Command
public void open(@ContextParam(ContextType.TRIGGER_EVENT) OpenEvent evt) {
    Groupbox box =  (Groupbox)evt.getTarget();
    for (Component comp : box.getParent().getChildren()) {
        if (comp instanceof Groupbox) {
            ((Groupbox)comp).setOpen(false);
        }
    }
    box.setOpen(evt.isOpen());
}

This should do what you want.

Greetz chill.

link publish delete flag offensive edit

Comments

Thank you for helping.Now it's working fine.One small issue when click on first groupbox it's open,when i click on second groupbox both first and second box at a time open.My issue is at a time only one group box open,but my code open multiple groupbox.

sathishk ( 2016-01-09 11:26:17 +0800 )edit

You need to close the other ones with close in the onopen event

chillworld ( 2016-01-09 13:35:50 +0800 )edit

Can you provide sample event for dynamic groupbox?.

sathishk ( 2016-01-11 05:49:23 +0800 )edit

Thank You Very much Chillworld.

sathishk ( 2016-01-12 05:14:56 +0800 )edit

your welcome.

chillworld ( 2016-01-12 06:25:46 +0800 )edit
Your answer
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
1 follower

RSS

Stats

Asked: 2016-01-06 13:12:28 +0800

Seen: 23 times

Last updated: Jan 11 '16

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