0

Templates for grid's with variable number of columns?

asked 2012-08-03 06:29:02 +0800

davout gravatar image davout
1435 3 18

Is it possible (or are there any plans) to allow templates to be used to allow a grid to have a variable number of columns?

delete flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2012-08-03 06:54:07 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

updated 2012-08-03 07:02:43 +0800

Hi Davout,

Is this what you asked for?

<!-- ZUL -->
<grid apply="org.zkoss.bind.BindComposer" 
 viewModel="@id('vm') @init('foo.FooVM)">
	<columns children="@init(vm.foo)">
		<template name="children" var="node">
			<column label="@load(node)" />
		</template>
	</columns>
</grid>

with VM :

package foo;
public clas FooVM {
	public String[] getFoo() {
		return new String[]{"1", "2", "3"};
	}
}

Regards,
Monty Pan

link publish delete flag offensive edit

answered 2012-08-03 09:12:43 +0800

davout gravatar image davout
1435 3 18

Yes, but in my case its a mix of predefined/static columns plus an variable number of additional columns

link publish delete flag offensive edit

answered 2012-08-03 09:53:13 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

Hi Davout,

Sorry, I am not sure what you mean.
Maybe you can give a scenario.

In my personal opinion, I will use @template to approach.

Regards,
Monty Pan

link publish delete flag offensive edit

answered 2012-08-03 13:16:42 +0800

davout gravatar image davout
1435 3 18

updated 2012-08-03 16:19:23 +0800

Take the following situation where I want to display a grid of product sales by market:
* rows = products
* columns = markets

There will be a unknown/variable number of markets.

The columns will be:
column 1 - product name
column 2 - product category
column 3 - market #1
column 4 - market #2
column 5 - market #3
...
...
column n - market #n

Columns 1 and 2 will always be present. Columns 3 onwards will be varaible

link publish delete flag offensive edit

answered 2012-08-05 10:55:49 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

Hi Davout,

There is one question : Is this the Component's responsibility? or Developer's duty?
In my personal opinion, this is developer's duty.

For your situation, I wrote a simple example, and put it on Github.
Or you can read these files directly (url might change in the feature)
dynamicGrid.zul
DynamicGridVM.java

link publish delete flag offensive edit

answered 2012-08-05 13:20:24 +0800

davout gravatar image davout
1435 3 18

Unless I'm missing something your example doesn't inject columns into the grid. I'm looking for column titles

link publish delete flag offensive edit

answered 2012-08-05 13:37:08 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

Sorry for misunderstand your situation, but the example I provide is showing the possibility.
<Columns> or <Rows>, the logical is the same : please transform (or generate) your data structure into List<String>.

link publish delete flag offensive edit

answered 2012-08-20 06:37:05 +0800

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

Hi Monty,
Please change ur example pom.xml entry(In GitHub) for Zk Version.
Thanks

link publish delete flag offensive edit

answered 2012-08-22 08:01:08 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Hi Davout,

If you can use rowRenderer then you can control columns easily, please refer to http://www.zkoss.org/forum/listComment/20167-Extending-Grid-with-programmatically-configured-columns-position

Regards,
Ben

link publish delete flag offensive edit

answered 2012-09-01 10:34:17 +0800

davout gravatar image davout
1435 3 18

I've still yet to see a demo that shows a MVVM template used to build a grid with variable number of columns where column titles are included.

Also, how would the cell level binding work when at the moment the binding bean name can't include array names like 'vm.column[8].title' ?

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
2 followers

RSS

Stats

Asked: 2012-08-03 06:29:02 +0800

Seen: 874 times

Last updated: Sep 18 '12

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