0

Decimalbox inside Listcell - disable/enable

asked 2010-02-25 08:12:02 +0800

danielgoodwin gravatar image danielgoodwin
76 2

ZK 3.63

I have a listbox with two columns (string,BigDecimal). What I want to be able to do is
- populate list box in readonly state first
- click on an 'edit button' to enable the decimal field entry
- allow changes, and use 'save' button to commit changes

I can populate listbox fine and have decimalbox within listcell which is initially disabled
When i click edit I 'try' to programmatically access the decimalbox to enable it but the code only seems to see
1 column (listItem.getChildren() returning 1) and certainly none of the listcells is returning ANY children.

The listbox.itemcount is returning correct count (8 lines)


Zul
<listbox id="listBoxXXX" vflex="true"
width="99.5%"height="100%" multiple="false">
<listhead sizable="true">
<listheader id="listheader_1" label="col 1'" sort="none" width="60%" />
<listheader id="listheader_2" label="col2" sort="none" align="right" width="40%" />
</listhead>
</listbox>


// populate code
List<XXObj> lstArr =myService.get...();
ListModelList lst1 = new ListModelList();
lst1.addAll(lstArr);
listBox_XXX.setModelList(lst1);
listBox_XXX..setItemRenderer(new MyItemRenderer());

// Renderer
...
public void render(Listitem item, Object data)
{
MyObj obj = (MyObj)data;

Listcell lc = new Listcell(obj.getDescription());
item.appendChild(lc);

Decimalbox dBox = new Decimalbox();
dBox.setValue(new BigDecimal(obj.getValue()));

lc = new Listcell();
lc.appendChild(dBox);
item.appendChild(lc);

}

// Code to set readonly (trying to use objects at moment while I understand structure) ..

List<Listitem> lstArr = listBox_XXX.getItems();
logger.debug("Count items :" + listBox_XXX.getItemCount());
// for (Listitem lstItem : lstArr)
for (Object item : listBox_XXX.getItems()) {
logger.debug("item :" + item);
if (item instanceof Listitem) {
Listitem lstItem = (Listitem) item;
for (Object cell : ((Listitem) lstItem).getChildren()) {
logger.debug("cell :" + cell);
// CHILDREN COUNT is ALWAYS 1
if (cell instanceof Listcell) {
Listcell listcell = (Listcell) cell;

logger.debug("cell :" + listcell.getLabel());
for (Object innercell : listcell.getChildren()) {
// NEVER GET HERE

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-02-26 02:27:51 +0800

danielgoodwin gravatar image danielgoodwin
76 2

Probably in wrong forum - moving to help ..

link publish delete flag offensive edit

answered 2010-02-26 02:55:14 +0800

PeterKuo gravatar image PeterKuo
481 2

Please don't cross post.
refer to your other thread
http://www.zkoss.org/forum/listComment/11460

link publish delete flag offensive edit

answered 2010-02-26 09:59:05 +0800

danielgoodwin gravatar image danielgoodwin
76 2

Ok I appear to have solved this by 'simply' using two ListItemRenderers

For the readonly I just use a Listcell and set its text.

    lc = new Listcell(String.format("%.2f", obj.getDeclaredValue()));
    item.appendChild(lc);

When I want to edit the listcell, I simply
change the ItemRender to one with a decimalbox for the value and catch the onchange event
which I then use to update the data stored with the listitem itself (item.setAttribute("data", someObj");

Decimalbox dBox = new Decimalbox();
dBox.setValue(new BigDecimal(obj.getDeclaredValue()));

dBox.addEventListener(Events.ON_CHANGE, new EventListener(){
				   public void onEvent(Event arg0) throws Exception{ 
    Decimalbox dBox = (Decimalbox) arg0.getTarget();
...

    ;}
});
lc = new Listcell();
lc.appendChild(dBox);
item.appendChild(lc);

link publish delete flag offensive edit

answered 2010-02-26 10:10:21 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

I have checked your code in the other thread :-(

So, that's exactly, why not do cross post :-)

best
Stephan

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-02-25 08:12:02 +0800

Seen: 604 times

Last updated: Feb 26 '10

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