1

How to select/diaselect all in listbox

asked 2013-07-11 05:58:38 +0800

susu gravatar image susu
11 2

updated 2013-07-11 06:21:02 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

i put multiple= true n checkmark= true, but it still remain as radiobutton not checkbox

<listbox id="lbxSdata" fixedLayout="true" multiple="true" checkmark="true" sizedByContent="false" span='true'  
            emptyMessage="${lbl:name('No items match your search')}">
                <listhead sizable="true" >
                <listheader hflex="3" label="${lbl:name('Action')}" align="left" />
                <listheader hflex="10" sort="auto(LOCK_TABLE)" label="${lbl:name('Table')}" align="left" />
                <listheader hflex="20" sort="auto(LAST_OPR_DATE)" label="${lbl:name('Last Date')}" align="left" />
                <listheader hflex="20" sort="auto(LOCK_KEY1)" label="${lbl:name('Key 1')}" align="left" />
                <listheader hflex="5" sort="auto(LOCK_KEY2)" label="${lbl:name('Key 2')}" align="left" />
                <listheader hflex="5" sort="auto(LOCK_KEY3)" label="${lbl:name('Key 3')}" align="left" />
                <listheader hflex="5" sort="auto(LOCK_KEY4)" label="${lbl:name('Key 4')}" align="left" />
                <listheader hflex="5" sort="auto(LOCK_KEY5)" label="${lbl:name('Key 5')}" align="left" />
                <listheader hflex="5" sort="auto(LOCK_REMARK)" label="${lbl:name('Remarks')}" align="left" />
                </listhead>
            </listbox>
delete flag offensive retag edit

Comments

There is no model set in your listbox,neither you are using any listitem,hope you are using in your code,and havn't displayed here.

nsharma ( 2013-07-11 07:02:42 +0800 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-11 06:10:30 +0800

iamsudhir4u gravatar image iamsudhir4u flag of India
545 7
http://corejavasupport.bl...

You need to set multiple equals true on your VM.

For Example:

ListModelList LML = new ListModelList();

LML.setMultiple(true);
link publish delete flag offensive edit
0

answered 2013-07-11 07:45:38 +0800

susu gravatar image susu
11 2

tq i got this :)

link publish delete flag offensive edit
0

answered 2013-07-11 07:47:06 +0800

susu gravatar image susu
11 2

but once i link it to java, the select all checkbox in header will disappear..why it happen like that?

link publish delete flag offensive edit

Comments

Kindly share your demo code..

iamsudhir4u ( 2013-07-11 08:20:43 +0800 )edit
0

answered 2013-07-11 08:42:28 +0800

susu gravatar image susu
11 2
@Override
public void doBeforeComposeChildren(Component lockmst) throws Exception
{
    super.doBeforeComposeChildren(lockmst);
    System.out.println("doBeforeComposeChildren ...");

}

@SuppressWarnings("unchecked")
@Override
public void doAfterCompose(Component lockmst) throws Exception
{
    super.doAfterCompose(lockmst);
    wdwLockmstSearch.addEventListener(Events.ON_CLICK, this);

    // set RowRederer to Data Grid
    lbxSdata.setItemRenderer(new LockmstRowRenderer(this));
    ZkGuiUtil.setNoEmptyBgColorFields(wdwLockmstSearch);
    System.out.println("doAfterCompose ...");

    // init
}

public void onClick$btnSearch()
{
    startPageNumber = 0;
    hprmSearch = loadSearchCriteria();
    refreshModel(startPageNumber, hprmSearch);
}

public void onPaging$sdataPaging(ForwardEvent event)
{
    final PagingEvent pe = (PagingEvent) event.getOrigin();

    startPageNumber = pe.getActivePage();
    hprmSearch = loadSearchCriteria();
    refreshModel(startPageNumber, hprmSearch);
}

private void refreshCurrentPage()
{
    if (hprmSearch != null)
        refreshModel(startPageNumber, hprmSearch);

}

private HParam loadSearchCriteria()
{
    HParam hParam = new HParam();

    hParam.putString("LOCK_TABLE", txtLOCK_TABLE.getValue());

    hParam.putString("LOCK_KEY1", txtLOCK_KEY1.getValue());
    hParam.putString("LOCK_KEY2", txtLOCK_KEY2.getValue());
    hParam.putString("LOCK_KEY3", txtLOCK_KEY3.getValue());

    return (hParam);
}

private void refreshModel(int _startPageNumber, HParam _scriteria)
{
    int pageSize = PageUtil.getLinesPerPage();
    sdataPaging.setPageSize(pageSize);

    if (_startPageNumber == 0) // first page
        sdataPaging.setActivePage(0); // reset it

    model = new LockmstPagingListModel(pageSize);
    model.getPageData(_startPageNumber, _scriteria);
    sdataPaging.setTotalSize(model.getTotalSize());
    model.setMultiple(true);
    lbxSdata.setModel(model);
}

@Override
public void onEvent(Event event) throws Exception
{
    super.onEvent(event);


    if (event.getTarget() instanceof Window
            && event.getName().equals(Events.ON_CLICK))
    {
        Object obj = event.getData();
        if (obj != null && obj instanceof String
                && obj.equals(ZkConstants.refreshCurrentPage))
        {
            refreshCurrentPage();
        }
    } else if (event.getTarget() instanceof Listcell
            && event.getName().equals(Events.ON_CLICK))
    {
        Listcell lc = (Listcell) event.getTarget();
        String action = (String) lc.getAttribute(ZkConstants.Action);
        if (action != null && action.equals("viewDetail"))
        {
            viewDetail(event);
        }
    } else if (event.getTarget() instanceof Listbox
            && event.getName().equals(Events.ON_SELECT))
    {
        onSelectSearchResult(event);
    }

}

@SuppressWarnings("unchecked")
private void onSelectSearchResult(Event event)
{
    Listbox lb = (Listbox) event.getTarget();

    Object obj[] = lb.getSelectedItems().toArray();
    for (int i = 0; i < obj.length; i++)
    {
        Listitem listitem = (Listitem) obj[i];
        listitem.setSelected(true);
        listitem.setDisabled(true);

        @SuppressWarnings("unused")
        Map<String, String> map = (Map) listitem
                .getAttribute(ZkConstants.RowData);
        // System.out.println(map);
    }
}

@SuppressWarnings("unchecked")
private void viewDetail(Event event)
{
    Listcell lc = (Listcell) event.getTarget();
    String action = (String) lc.getAttribute(ZkConstants.Action);
    Map<String, String> map = (Map<String, String>) lc
            .getAttribute(ZkConstants.RowData);
    if (action == null)
        action = "";
    map.put(ZkConstants.MaintMode, ZkConstants.MaintModeView);
    Executions.createComponents(LockmstSearch, wdwLockmstSearch,
            map);

}

@SuppressWarnings("unchecked")
public void onClick$btnDelete()
{

     String msg = "Are you sure you want to proceed?";
     ZkGuiUtil.showQuestion(msg, new EventListener()
     {
        public void onEvent(Event evt) throws Exception
        {
         switch (((Integer) evt.getData()).intValue())
         {
            case Messagebox.OK:
              deleterecord();
              break; // the OK button is pressed
            case Messagebox.CANCEL:
              break; // the CANCEL button is pressed
         }
        }
     });}

// @SuppressWarnings("unchecked") // public void onClick$btnDeleteAll() // { //
// String msg = "Are you sure you want to proceed?"; // ZkGuiUtil.showQuestion(msg, new EventListener() // { // public void onEvent(Event evt) throws Exception // { // switch (((Integer) evt.getData()).intValue()) // { // case Messagebox.OK: // deleterecord(); // break; // the OK button is pressed // case Messagebox.CANCEL: // break; // the CANCEL button is pressed // } // } // });} public void deleterecord() {

    Map map = (Map) lbxSdata.getSelectedItem().getAttribute(
            ZkConstants.RowData);

    LockmstDeleteRec delRec = new LockmstDeleteRec();
    delRec.delRecords(map.get("LOCK_TABLE").toString(),
        map.get("LOCK_KEY1").toString(),
        map.get("LOCK_KEY2").toString()
        ,map.get("LOCK_KEY3").toString(),
        map.get("LOCK_KEY4").toString(),
        map.get("LOCK_KEY5").toString(),
        map.get("LOCK_KEY6").toString()
        ,map.get("LOCK_KEY7").toString(),
        map.get("LOCK_KEY8").toString(),
        map.get("LOCK_KEY9").toString(),
        map.get("LOCK_KEY10").toString());

    refreshModel(startPageNumber, hprmSearch);
}

}

link publish delete flag offensive 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: 2013-07-11 05:58:38 +0800

Seen: 28 times

Last updated: Jul 11 '13

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