Read-time data refresh for listgrid.
刷新listgrid只需要调用其select-page方法就可以,实现实时刷新,可以在新线程中建立一个函数调用循环循环来调用b:listgrid的select-page方法。代码如下:
xml 代码
- <b:listgrid id="movies-listgrid" b:template="listgrid.xsl" style="height:280px;" b:url="listgrid-data.xml" b:page-number="1" b:page-size="20" b:items-in-total="1000">
- <s:event b:on="command">
- <s:task b:action="alert" b:value="{'The event comes from row: ', (count($_mouseElement/ancestor::tr/preceding-sibling::tr) + 1)}"
- b:test="$_mouseElement/name()='input'" />
- s:event>
- <b:listgridhead>
- <b:listgridrow>
- <b:listgridheadcell b:datatype="text">Titleb:listgridheadcell>
- <b:listgridheadcell b:datatype="text">Directorb:listgridheadcell>
- <b:listgridheadcell b:datatype="genre">Genreb:listgridheadcell>
- <b:listgridheadcell b:datatype="text">Languageb:listgridheadcell>
- <b:listgridheadcell b:datatype="datepicker" b:sorttype="string">Premiereb:listgridheadcell>
- b:listgridrow>
- b:listgridhead>
- <b:listgridbody />
- b:listgrid>
- div>
- <div>
- refresh every second
- <s:event b:on="command">
- >
- <s:task b:action="trigger" b:event="refresh-listgrid" b:async="true" />
- s:event>
- <s:event b:on="refresh-listgrid">
- <s:task b:action="trigger" b:event="select-page" b:target="id('movies-listgrid')"/>
- <s:task b:action="trigger" b:event="refresh-listgrid" b:delay="1000"/>
- s:event>
- div>