Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8842241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:54:33+00:00 2026-06-14T10:54:33+00:00

I need to reload data in ZK pivot table when ombobox onchange event trigger.

  • 0

I need to reload data in ZK pivot table when ombobox onchange event trigger.

If user change the value from the comobox { as shown in below code } data should change based on user selection.

index.zul

<window apply="org.zkoss.pivot.demo.PivotDemoBaseController"  >
    <hlayout>
        <panel id="main" hflex="1" border="normal">
            <caption label="2012 Data">
                <toolbarbutton id="exportCsvBtn" label="Export CSV"  />
                <toolbarbutton id="exportXlsBtn" label="Export XLS" />
                <toolbarbutton id="exportXlsxBtn" label="Export XLSX" />
            </caption>
            <panelchildren>
                <vlayout spacing="0">
                    <pivottable id="pivot" hflex="1" pageSize="15"  >





                        <combobox model="${lm}"  id="selectGeo"/>
                        <div>All People</div>
                    </pivottable>
                    <div id="descDiv" />
                </vlayout>
            </panelchildren>
        </panel>
        <panel id="field" title="Control" width="300px" border="normal"  >
            <panelchildren>
                <vlayout style="padding: 10px">
                    <!-- Predefined scenario: -->
                    <hlayout id="preDef" spacing="0"  />
                    <div class="footnote" style="padding: 5px 0">(Drag fields among the areas below)</div>
                    <pivot-field-control id="pfc" height="300px" />
                    <hlayout hflex="1">
                        <checkbox id="autoUpdate" label="Auto Update" checked="true" />
                        <div hflex="1" />
                        <!-- <button id="updateBtn" label="Update" disabled="true" autodisable="+self" /> -->
                    </hlayout>
                    <separator />
                    <checkbox id="colGrandTotal" label="Enable grand total for columns" />
                    <checkbox id="rowGrandTotal" label="Enable grand total for rows" />
                    <div>
                        <radiogroup id="dataOrient">
                            Data field orientation:
                            <radio id="colOrient" label="column" />
                            <radio id="rowOrient" label="row" />
                        </radiogroup>
                    </div>
                </vlayout>
            </panelchildren>
        </panel>
    </hlayout>
</window>

Below is the code of my Controller

public class PivotDemoBaseController extends SelectorComposer {

private static final long serialVersionUID = -7531153593366258488L;

private static final String[] TITLES = new String[] { "(Data Title)", "(Column Title)", "(Row Title)" };


@Wire
private Pivottable pivot;

@Wire
private PivotFieldControl pfc;

@Wire
private Button updateBtn;

@Wire
private Checkbox colGrandTotal, rowGrandTotal;

@Wire
private Radio colOrient, rowOrient;

@Wire
private Hlayout preDef;

@Wire
private Div descDiv;

private TabularPivotModel _model;

@Wire
private Combobox selectGeo;




private CellStyleConfigurator styleConfigurator;

public void onCheck$autoUpdate(CheckEvent event) {
    boolean deferred = !event.isChecked();
    pfc.setDeferredUpdate(deferred);
    if (!deferred)
        updateBtn.setDisabled(true);
}


@Listen("onChange = #selectGeo")
public void onChangeSelectGeo(Event event) {        
     String geography = selectGeo.getValue();
   System.out.println("Value---"+geography);

}

public void onClick$updateBtn() {
    pfc.update();
}

public void onPivotFieldControlChange$pfc() {
    if (!pfc.isUpdated())
        updateBtn.setDisabled(false);
}

public void onCheck$colGrandTotal(CheckEvent event) {
    System.out.println("PivotDemoBaseController.onCheck$colGrandTotal()");
    pivot.setGrandTotalForColumns(event.isChecked());
}

public void onCheck$rowGrandTotal(CheckEvent event) {
    pivot.setGrandTotalForRows(event.isChecked());
}

public void onCheck$dataOrient(CheckEvent event) {
    pivot.setDataFieldOrient(((Radio)event.getTarget()).getLabel());
}

public void onClick$exportCsvBtn() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PivotExportContext context = Exports.getExportContext(pivot, true, TITLES);
    Exports.exportCSV(out, context);
    Filedownload.save(out.toByteArray(), "text/csv", "pivot.csv");
    try {
        out.close();
    } catch (IOException e) {}
}

public void onClick$exportXlsBtn() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PivotExportContext context = Exports.getExportContext(pivot, true, TITLES);
    Exports.exportExcel(out, "xls", context, styleConfigurator);
    Filedownload.save(out.toByteArray(), "application/vnd.ms-excel", "pivot.xls");
    try {
        out.close();
    } catch (IOException e) {}
}

public void onClick$exportXlsxBtn() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PivotExportContext context = Exports.getExportContext(pivot, true, TITLES);
    Exports.exportExcel(out, "xlsx", context, styleConfigurator);
    Filedownload.save(out.toByteArray(), "application/vnd.ms-excel", "pivot.xlsx");
    try {
        out.close();
    } catch (IOException e) {}
}

@NotifyChange("*")
@Override
public void doAfterCompose(Component comp) throws Exception {
    System.out.println("PivotDemoBaseController.doAfterCompose()");
    super.doAfterCompose(comp);
    StaticPivotModelFactory pmf = StaticPivotModelFactory.INSTANCE;

    //PivotModelFactory pmf= (PivotModelFactory) arg.get("factory");
    _model = pmf.build();
    pivot.setModel(_model);
    pfc.setModel(_model);
    Executions.createComponents(pmf.getDescriptionURI(), descDiv, null);

    loadConfiguration(pmf.getDefaultConfigurator());

    // load predefined scenario
    for(PivotConfigurator conf : pmf.getConfigurators())
        preDef.appendChild(getPreDefDiv(conf));
}

private void initControls() {
    System.out.println("PivotDemoBaseController.initControls()");
    // grand totals
    colGrandTotal.setChecked(pivot.isGrandTotalForColumns());
    rowGrandTotal.setChecked(pivot.isGrandTotalForRows());

    // data orientation
    ("column".equals(pivot.getDataFieldOrient()) ? 
            colOrient : rowOrient).setChecked(true);

    pfc.syncModel(); // field control
}

private Component getPreDefDiv(final PivotConfigurator conf) {
    Div div = new Div();
    div.setHflex("1");
    div.setSclass("predef");
    div.appendChild(new Label(conf.getTitle()));
    div.addEventListener("onClick", new EventListener(){
        public void onEvent(Event event) throws Exception {
            loadConfiguration(conf);
        }
    });
    return div;
}

private void loadConfiguration(PivotConfigurator conf) {
    System.out.println("PivotDemoBaseController.loadConfiguration()");
    _model.clearAllFields(true);
    conf.configure(_model);
    conf.configure(pivot);
    pivot.setPivotRenderer(conf.getRenderer());
    styleConfigurator = conf.getCellStyleConfigurator();
    initControls();
}

}

Any Help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:54:34+00:00Added an answer on June 14, 2026 at 10:54 am

    I think you mean the @NotifyChange annotation, but it is for MVVM data-binding, which you did not use.
    You can switch to the MVVM data binding or you schould update it like this:

    @Listen("onChange = #selectGeo")
    public void onChangeSelectGeo(CheckEvent event) {
        // Manipulate pivot element here.
    }
    

    For more info, see CheckEvent and MVVM vs MVC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method in my NSTableViewDelegate class to reload the data table from
I need to call an Ajax script to reload data from a child window.
I have a UI table view loading data from network. If the user move
I sometimes reload table data and I need to redraw the table so that
I have the following scenario where I need to reload a table in SQL
I'm using a UITableView which loads data from a server. I need to use
My Django app displays data from a database. This data changes without user intervention,
On my site I need to request a date/time every page reload. The reason
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
So I need to AJAX-reload part of a page, and so I'm building a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.