0

Hide row in dynamic grid

asked 2013-09-23 19:14:34 +0800

p00ya00 gravatar image p00ya00
1

Hi.

I am trying to hide/show a row in a grid (filled dynamically from Java code) upon clicking on it's previous row. To simulate a simple MasterDetail component. I get the right index of the clicked row in the java code, however changing visibility of the row doesn't work! Can anyone help me with this or is there a similar way to to this?

Thanks, Pooya

Here is the code for the ZUL:

<?xml version="1.0" encoding="UTF-8"?>
<zk>
    <window id="callbackLogWindow"
            apply="CallbackLogWindowComposer"
            border="none" height="100%" width="100%">
        <grid id="callbackLogGrid" oddRowSclass="non-odd" height="100%">
            <columns>
                <column label="Logging Name" />
                <column label="Status" />
                <column label="DateTime" />
                <column label="Subject" />
                <column label="Replies" />
            </columns>
            <rows>
                <zk forEach="${callbackLogWindow$composer.callbacks}">
                    <row sclass='${forEachStatus.index % 2 != 0 ? "z-grid-odd" : ""}'
                    onClick="callbackLogWindow$composer.toggleRow(self.index)">
                        <custom-attributes callback="${each}"/>
                        <cell><label value="${callback.loggingName}" /></cell>
                        <cell><label value="${callback.resolved}" /></cell>
                        <cell><label value="${callback.callbackTime}" /></cell>
                        <cell><label value="${callback.subject}" /></cell>
                        <cell><label value="${callback.resolvedItemCount}" /></cell>
                    </row>
                    <row sclass='${forEachStatus.index % 2 != 0 ? "z-grid-odd" : ""}'>
                        <cell colspan="5">
                            <include src="callbackItem.zul" callback="${each}"/>
                        </cell>
                    </row>
                    <row>
                        <custom-attributes callback="${each}"/>
                        <button onClick="callbackLogWindow$composer.saveCallbackItems(callback)">
                           Save
                        </button>
                    </row>
                </zk>
            </rows>
        </grid>
    </window>
</zk>

And the controller:

public class CallbackLogWindowComposer extends SelectorComposer<window> {

@Inject private CallbackDao callbackDao;
@Wire Grid callbackLogGrid;
private List<Callback> callbacks = new ArrayList<Callback>();

@Override
public void doAfterCompose(Window window) throws Exception {

    super.doAfterCompose(window);
}

public List<Callback> getCallbacks() {

    callbacks = callbackDao.findAll();
    return callbacks;
}

public void toggleRow(int i) {

    Component row = callbackLogGrid.getRows().getChildren().get(i+1);
    row.setVisible(row.isVisible());
    callbackLogGrid.renderAll();
}

public void saveCallbackItems(Callback cb) {
    callbackDao.saveInTransaction(cb);
}

}

delete flag offensive retag 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
1 follower

RSS

Stats

Asked: 2013-09-23 19:14:34 +0800

Seen: 30 times

Last updated: Sep 23 '13

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