0

Change listbox columns order

asked 2012-08-01 11:10:09 +0800

Neus gravatar image Neus
1415 14

Hi,

I have this listbox:

<listbox  id="LBSeguimiento"  mold="paging" pagingPosition="bottom" 
autopaging="true" width="99.8%" sizedByContent="true" span="4" vflex="true"
model="@load(vm.beans)" selectedItem="@bind(vm.beanSeleccionado)">
	 <listhead sizable="true" >
	 	<listheader id = "LHEstado" label="_Estado" visible="true" sort="auto(estado)"/>
	 	<listheader id = "LHEntidad" label="_Entidad" visible="true" sort="auto(entidad)"/>
		<listheader id = "LHPais" label="_Pais" visible="true" sort="auto(pais)"/>
		<listheader id = "LHProvincia" label="_Provincia" visible="true" sort="auto(provincia)"/>
		<listheader id = "LHComarca" label="_Comarca" visible="true" sort="auto(comarca)"/>
		<listheader id = "LHpoblacion" label="_Poblacion" visible="true" sort="auto(poblacion)"/>
		<listheader id = "LHTipoServicio" label="_TipoServicio" visible="true" sort="auto(tipoServicio)"/>
		<listheader id = "LHEspecialidad" label="_Especialidad" visible="true" sort="auto(especialidad)"/>
		<listheader id = "LHProveedor" label="_Proveedor" visible="true" sort="auto(proveedor)"/>
	</listhead>
        <template name="model" var="item">
			<listitem value="@load(item)" onDoubleClick="@command('DobleClickFila')" style="@load(item.registroNuevo  eq 0 ? '' : 'background-color:orange')">
			<listcell label="@load(item.estado) @converter(vm.myConverter)"  style="text-align:center" /> 
			<listcell label="@load(item.entidad)" tooltiptext="@load(item.entidad)" style="text-align:left"/>
			<listcell label="@load(item.pais)" tooltiptext="@load(item.pais)"/>
			<listcell label="@load(item.provincia)" tooltiptext="@load(item.provincia)"/>
			<listcell label="@load(item.comarca)" tooltiptext="@load(item.comarca)"/>
			<listcell label="@load(item.poblacion)" tooltiptext="@load(item.poblacion)"/>
			<listcell label="@load(item.tipoServicio)" tooltiptext="@load(item.tipoServicio)" style="@load(item.estiloServicio)"/>
			<listcell label="@load(item.especialidad)" tooltiptext="@load(item.especialidad)"/>
			<listcell label="@load(item.proveedor)" tooltiptext="@load(item.proveedor)"/>
		</listitem>
	</template>
</listbox>

I have a footer with a button that opens a window that allows the user to set up the view of the listbox (its order and what columns user wants to be visibile).
When user closes that window it returns two array of listheaders: one with the visible ones and the other with the invisibles.
Setting them visibile/invisible is easy because I go over these two arrays and make columns visible/invisible deppeding on user selection.

But I don't know how to change the order of the visible columns. I tried using insertBefore() but it only changes the header not all the column.

Maybe I should change something related to the bean instead of the component???
Any idea???


Thank you!

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2012-08-01 13:04:57 +0800

xcemus gravatar image xcemus
12

Hi Neus,

have you seen our open-source library ZK-DL? It is published under LGPL. We have solved all these issues and provide the functionality to users as a default simple-to-use behavior. But the library doesn't support ZK6 yet, nowadays I am working on it so it should be done in couple says, I hope. If you want you can look at it and use it or just for an inspiration. The current version can be found on GitHub, ZK-DL project.

Anyway ... in old versions of ZK there was listitem used as a template and you had to catch it and modify it. In ZK 6 they are using component definition instead. I have not found a clear way how to get it so I have to use a java reflection to extract it from template.

comp.getTemplate("model")

I hope a helped you.

Regards,
Karel

link publish delete flag offensive edit

answered 2012-08-02 06:51:44 +0800

Neus gravatar image Neus
1415 14

Hi Karel,
ZK-DL looks great! And it resolve a lot of things I'm having trouble (filtering, columns configuration, extracting to excel...)
But as I am using ZK6 I think I can't use it, right?

I will wait until it is done for ZK 6 and now try to do something with the template...

Thank you!

link publish delete flag offensive edit

answered 2012-08-02 07:29:52 +0800

Neus gravatar image Neus
1415 14

I can't access the listcells from getTemplate() to change its order...

link publish delete flag offensive edit

answered 2012-08-19 12:41:51 +0800

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

updated 2012-08-19 12:42:44 +0800

Can reordering of column is possible with ZK-DL ,something which i want mentioned here See this Forum Question

link publish delete flag offensive edit

answered 2012-08-19 19:28:43 +0800

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

Hi Xcemus i was trying to checkout ur project from svn but when i am trying to run mvn install i am getting this exception .
Failed to execute goal on project ZKDLTutorial: Could not resolve dependencies for project cz.datalite.zk-dl:ZKDLTutorial:war:1.3.0: Failed to collect dependencies for [org.springframework:spring-context:jar:3.0.5.RELEASE (compile), org.springframework:spring-orm:jar:3.0.5.RELEASE (compile), org.springframework:spring-web:jar:3.0.5.RELEASE (compile), org.springframework.security:spring-security-core:jar:3.0.5.RELEASE (compile), org.zkoss.zk:zk:jar:5.0.10 (compile), org.zkoss.zk:zul:jar:5.0.10 (compile), org.zkoss.zk:zhtml:jar:5.0.10 (compile), org.zkoss.common:zcommon:jar:5.0.10 (compile), org.zkoss.common:zweb:jar:5.0.10 (compile), org.zkoss.zkforge.el:zcommons-el:jar:1.1.0 (compile), cz.datalite.zk-dl:ZKComposer:jar:1.3.0 (compile), cz.datalite.zk-dl:SpringService:jar:1.3.0 (compile), cz.datalite.zk-dl:ZKDLComponents:jar:1.3.1 (compile), cz.datalite.zk-dl:ZKDLComponentsHibernateExt:jar:1.3.0 (compile), cz.datalite.zk-dl:ZKComponents:jar:1.3.0 (compile), cz.datalite.zk-dl:zkplus:jar:1.3.0 (compile), cz.datalite.zk-dl:ZKStatistics:jar:1.3.0 (compile), junit:junit:jar:4.8.1 (test), commons-dbcp:commons-dbcp:jar:1.2.1 (compile), commons-collections:commons-collections:jar:3.2.1 (compile), org.slf4j:slf4j-api:jar:1.5.8 (compile), log4j:log4j:jar:1.2.14 (compile), org.slf4j:slf4j-log4j12:jar:1.5.8 (compile), hsqldb:hsqldb:jar:1.8.0.7 (compile), cz.datalite.zk-dl:Selenium:jar:1.3.0 (compile)]: Failed to read artifact descriptor for cz.datalite.zk-dl:ZKComposer:jar:1.3.0: Could not transfer artifact cz.datalite.zk-dl:ZKComposer:pom:1.3.0 from/to jboss (http://repository.jboss.com/maven2): Access denied to: http://repository.jboss.com/maven2/cz/datalite/zk-dl/ZKComposer/1.3.0/ZKComposer-1.3.0.pom, ReasonPhrase:Forbidden. -> [Help 1]

Please help me I am really need ur help.

link publish delete flag offensive edit

answered 2012-08-20 10:26:42 +0800

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

Hi Xcemus ,
When i am trying to run your example code Given Here Listbox - data driven components I am getting this Exception.


Source Codejava.lang.NoSuchMethodError: cz.datalite.zk.components.list.view.DLQuickFilter.setVariable(Ljava/lang/String;Ljava/lang/Object;Z)V
	cz.datalite.zk.components.list.view.DLQuickFilter.setController(DLQuickFilter.java:117)
	cz.datalite.zk.components.list.controller.impl.DLQuickFilterControllerImpl.<init>(DLQuickFilterControllerImpl.java:43)
	cz.datalite.zk.components.list.DLListboxGeneralController.initQuickFilter(DLListboxGeneralController.java:151)
	cz.datalite.zk.components.list.DLListboxGeneralController.doAfterCompose(DLListboxGeneralController.java:109)
	org.zkoss.zk.ui.impl.UiEngineImpl.doAfterCompose(UiEngineImpl.java:529)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:824)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:770)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:679)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:643)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:816)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:770)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:679)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:643)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:816)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:770)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:679)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:741)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:701)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:643)
	org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:394)
	org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:316)
	org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:215)
	org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:135)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

an you please guide me to resolve this issue

link publish delete flag offensive edit

answered 2013-04-05 06:39:38 +0800

snair33 gravatar image snair33 flag of United States
0

I stored list of columns in an array and used EL expressions and this was straight forward.

<listbox id="campaign_grid" sizedByContent="true"
    sclass="border:2px solid #ddd;" span="true" mold="default"
    model="@bind(vm.campaignReport)" selectedIndex="@bind(vm.selectedIndex)" >
    <listhead sizable="true" >
                   <!-- columnHeaders is a list of column header I would like 
                      to display -->
        <listheader label="${each}" forEach="${vm.columnHeaders}" />
    </listhead>
    <template name="model" var="row">
        <listitem>
            <zk forEach="${vm.columnHeaders}" >
                <listcell>
                                            <!--row is Map of column values -->
                    ${row.get(each)}
                </listcell>
            </zk>
        </listitem>
    </template>
</listbox>

Hope this helps.

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: 2012-08-01 11:10:09 +0800

Seen: 308 times

Last updated: Apr 05 '13

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