0

zk binding

asked 2012-10-09 15:43:42 +0800

afxgroup gravatar image afxgroup
126 1

Hello, i'm trying to use this code to use the data binding:

<zk>
	<window>
		<zscript>
			<![CDATA[
			    import com.wsm.mmo.beans.Table;
			    import com.wsm.zul.models.TablesModel;
			    import org.zkoss.bind.impl.BinderImpl;
			    
			    TablesModel model = new TablesModel();
			    
				void doOrientationChange(ClientInfoEvent evt) {
				    if ("portrait".equals(evt.getOrientation())) {
				        main.setWidth("100%");
				        Clients.resize(content);
				    } else {
				        if (!execution.isBrowser("mobile"))
				            main.setWidth("100%");
				        else
				            main.setWidth("80%");
				        Clients.resize(content);
				    }
				}
				
				void changeSomething() {
					Table tab = model.getTables().get(0);
					model.setCurrentTable(tab);
					tab.setDescription("cicciociccio1");
					model.setTable();
				}
			]]>
		</zscript>
		<vlayout id="main" onClientInfo="doOrientationChange((ClientInfoEvent)event)" width="${zk.mobile > 0 ? '80%' : '100%'}" apply="com.wsm.zul.controllers.TablesController" viewModel="@id('vm') @init(model)">
			<div id="content" sclass="main-content">
				<textbox id="mainTrigger" onChange="@command('refreshTables')"></textbox>
				<grid id="gridTables" model="@bind(vm.tables)" mold="paging" autopaging="true" vflex="true" >
					<auxhead>
	            		<auxheader label="Table List" colspan="5" />
	        		</auxhead>
	        		<columns>
	            		<column width="60px">Id</column>
	            		<column hflex="4">Table Name</column>
	            		<column hflex="5">Num Players</column>
	            		<column hflex="2">Buy In</column>
			        </columns>
			        <template name="model" var="table">
	                    <row>
	                    	<label value="@bind(table.tableid)"/>
		                    <label value="@bind(table.description)"/>
		                    <label value="@bind(table.numPlayer)"/>
		                    <label value="@bind(table.buy_in)"/>
	                    </row>
	            	</template>
				</grid>
			</div>
			<button onClick="changeSomething()" label="Change 1" /><button onClick="@command('setTable')" label="Change 2" />
		</vlayout>
	</window>
</zk>

Actually the data binding is correctly started at load. Now i want to change someting on my table using the first button. So i get a table and i change the description. but i cannot refresh automatically the grid. If i use the second button after the first one the grid is refreshed correctly. So my question is. Is there a way to use the @command also using zscript?

Thank you

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-10-10 09:33:05 +0800

psingh gravatar image psingh flag of India
963 8

To refresh the grid automatically we can use @NotifyChange("tables") on first Command button.You do not require to click on second button to refresh grid.

link publish delete flag offensive edit

answered 2012-10-10 11:23:48 +0800

afxgroup gravatar image afxgroup
126 1

No my question is differenr.. is there a way to refresh the data *without* pressing anything?? and so using the zscript for example when i receive an event on a queue??

link publish delete flag offensive edit

answered 2012-10-11 17:40:56 +0800

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

@afxgroup Inline Editing and when you will press this button it will save into the database otehrwsie inline will automatically changed it.

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-10-09 15:43:42 +0800

Seen: 118 times

Last updated: Oct 11 '12

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