[英]Struts2 JQuery grid - empty grid message
I'm using Struts2 JQuery grids and it works fine. 我正在使用Struts2 JQuery网格,并且工作正常。
Here is an example of grid: 这是网格的示例:
<s:url var="remoteurl" action="jsontable"/>
<sjg:grid
id="gridtable"
caption="Customer Examples"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
>
<sjg:gridColumn name="id" index="id" title="ID" formatter="integer" sortable="false"/>
<sjg:gridColumn name="name" index="name" title="Name" sortable="true"/>
<sjg:gridColumn name="country" index="country" title="Country" sortable="false"/>
<sjg:gridColumn name="city" index="city" title="City" sortable="false"/>
<sjg:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" formatter="currency" sortable="false"/>
</sjg:grid>
I would like to display a specific message when the grid is empty instead of showing an empty grid. 我想在网格为空时显示特定的消息,而不是显示为空网格。 I know that this can be done by encapsulating the whole grid in a s:if
statement but I would like to avoid retrieving information twice if the grid has contents (one for the if statement, then a second time for the grid itself). 我知道可以通过将整个网格封装在s:if
语句中来实现,但是如果网格包含内容,我想避免两次检索信息(一个用于if语句,第二次用于网格本身)。
Is there an option to do the following "isEmpty" message? 是否可以选择执行以下“ isEmpty”消息?
<sjg:grid
id="gridtable"
ifEmpty="No data to display!"
Or some other mechanism like that where I can display a button to create a new entry? 还是其他类似的机制,可以在其中显示按钮以创建新条目?
you can use the event onCompleteTopics and some script like this: 您可以使用事件onCompleteTopics和类似以下的脚本:
<script type="text/javascript">
$.subscribe('completegrid', function(event, data) {
var records = $('#gridtable').getGridParam('records');
if(records < 1) {
$('#gridcontainer').html('<span>none</span>');
}
});
</script>
<sjg:grid
...
onCompleteTopics ="completegrid"
...
>
See reference on http://code.google.com/p/struts2-jquery/wiki/GridTag#Topics 请参阅http://code.google.com/p/struts2-jquery/wiki/GridTag#Topics上的参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.