}
);
}
大概思路就这样
------解决方案--------------------上面是加载的处理方法,如果把代码再改一下就好了。
<table width="98%" align="center" class="grid-table" border="0"
cellspacing="0" cellpadding="3" style="table-layout:fixed;margin-top:1px">
<thead>
<tr>
<th class="grid-th" width="20px">
用户名
</th>
<th class="grid-th" width="20px" align="center" ><input type="checkbox" id="check_all" /></th>
<th class="grid-th" width="90px">
登录名
</th>
<th class="grid-th" width="70px">
密码
</th>
<th class="grid-th" width="90px">
是否有效
</th>
<th class="grid-th" width="90px">
操作
</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
<tfoot id="templateTr" style="display:none">
<tr class="{tr_class}">
<td class="grid-td" align="center"
style="text-overflow:ellipsis;overflow:hidden;white-space: nowrap;">
{username}
</td>
<td class="grid-td" align="center"
style="text-overflow:ellipsis;overflow:hidden;white-space: nowrap;">
{loginname}
</td>
<td class="grid-td" align="center"
style="text-overflow:ellipsis;overflow:hidden;white-space: nowrap;">
{pwd}
</td>
<td class="grid-td"
style="text-overflow:ellipsis;overflow:hidden;white-space: nowrap;">
{yxbz}
</td>
<td class="grid-td"
style="text-overflow:ellipsis;overflow:hidden;white-space: nowrap;">
{cz}
</td>
</tr>
</tfoot>
</table>
function query(url){
jQuery.ajax({
url:url
,data:encodeURI(encodeURI(condition))
,dataType:'json'
,success:function(data){
if (data.error != null){
alert(data.error);
return;
}
if(data.isLogin=="N"){
alert("未登录");
window.top.location.href="<%=contextPath%>/login.jsp";
return;
}
$('#tbody').html('');
var html = [];
var templateTr = $('#templateTr').html();
var len = data.items.length;
if (len == 0){
html.push('<tr><td class="grid-td" colspan="4" align="center" style="color:#F00;">查无数据</td></tr>');
isExport=false;
}
else{
for(var i = 0 ; i < len ; i++){
var o = data.items[i];
var tmp = templateTr;
tmp = tmp.replace(/\{username\}/g,(o.username == null ? ' ':o.username));
tmp = tmp.replace(/\{loginname\}/g,(o.loginname == null ? ' ':o.loginname));
tmp = tmp.replace(/\{pwd\}/g,o.pwd);
tmp = tmp.replace(/\{yxbz\}/g,o.yxbz==1?"有":"无");