easyui中datagrid的刷新和使用

飞舞的锄头 2014-02-26 02:12:31
代码如下,能正确初始化页面,但查询时只输出了json数据。 请大神看看哪里错了?
---------页面代码
<form name="f1" action="outlets_init.php"  method="post" >
<input type="text" class="easyui-datebox" id="bt" name="bt" value=<?php echo date('Y-m-d',strtotime('-7 day'))?>>
--to--<input type="text" class="easyui-datebox" id="et" name='et' value=<?php echo date('Y-m-d',time())?>>
<input type="submit" value="go" >
</form>
<br>
<p>default show last 7 days</p>
<br>
<div id="showR" >

</div>
<div id="initD" style="display: display">
<table id="xxoo" class="easyui-datagrid" title="outlets_daily_sales" style="width:890px;height:auto"
data-options="
singleSelect: true,
url: 'outlets_init.php',
rowStyler: function(index,row){
if (row.outdate == 'TOTAL'){
return 'background-color:#6293BB;color:#fff;font-weight:bold;';
}
}
">
<thead>
<tr>
<th data-options="field:'outdate',width:80">outdate</th>
<th data-options="field:'Qingpu',width:80">Qingpu</th>
<th data-options="field:'Wuxi',width:80">Wuxi</th>
<th data-options="field:'Foxtown',width:80">Foxtown</th>
<th data-options="field:'Suzhou',width:80">Suzhou</th>
<th data-options="field:'Beijing',width:60">Beijing</th>
<th data-options="field:'Shenyang',width:80">Shenyang</th>
<th data-options="field:'Xiamen',width:80">Xiamen</th>
<th data-options="field:'Chongqing',width:80">Chongqing</th>
<th data-options="field:'Chengdu',width:80">Chengdu</th>
<th data-options="field:'day_total',width:80">day_total</th>

</tr>
</thead>
</table>
<script >
$('#xxoo').datagrid('reload');
</script>

----------------处理查询和初始化json (outlets_init.php)
ob_start();
require_once 'DB_sybase.php';
ob_end_clean();
$db=DB::Connect();
$start_date = isset($_POST['bt']) ? str_replace('-','',$_POST['bt']) :str_replace('-','',date('Y-m-d',strtotime('-7 day')));
$end_date = isset($_POST['et']) ? str_replace('-', '',$_POST['et']) :str_replace('-','',date('Y-m-d',time()));

$result=$db->Q_init($start_date,$end_date);
$c1=0;
$c2=0;
$c3=0;
$c4=0;
$c5=0;
$c6=0;
$c7=0;
$c8=0;
$c9=0;
$result2 = array();
$items=array();
while($row1= sybase_fetch_array($result)){
$c1=$c1+$row1[1];
$c2=$c2+$row1[2];
$c3=$c3+$row1[3];
$c4=$c4+$row1[4];
$c5=$c5+$row1[5];
$c6=$c6+$row1[6];
$c7=$c7+$row1[7];
$c8=$c8+$row1[8];
$c9=$c9+$row1[9];

}
$result=$db->Q_init($start_date,$end_date);
while($row2= sybase_fetch_array($result)){

$row2['day_total']=$row2[1]+$row2[2]+$row2[3]+$row2[4]+$row2[5]+$row2[6]+$row2[7]+$row2[8];
array_push($items, $row2);
}

$items_sum=array('outdate'=>'TOTAL','Qingpu'=>$c1,'Foxtown'=>$c2,'Wuxi'=>$c3,
'Suzhou'=>$c4,'Beijing'=>$c5,'Shenyang'=>$c6,'Xiamen'=>$c7,'Chongqing'=>$c8,'Chengdu'=>$c9,
'day_total'=>$c1+$c2+$c3+$c4+$c5+$c6+$c7+$c8+$c9
);
array_push($items, $items_sum);

$result2["rows"] = $items;
echo json_encode($result2);

---------------------------效果


...全文
29349 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2014-02-26
  • 打赏
  • 举报
回复
参数搞错了,你的是bt,我写成st了,自己要对比下
飞舞的锄头 2014-02-26
  • 打赏
  • 举报
回复 1
引用 2 楼 bailin710258 的回复:
[quote=引用 1 楼 showbo 的回复:] 点击查询的时候再执行
$('#xxoo').datagrid('reload',{st:$('开始日期选择器').datebox('getValue'),et:$('结束日期选择器').datebox('getValue')});
你的应该是datebox组件,如果不行改成对应的组件名称
改成这样后,显示重新加载数据,但显示的内容却没变
<form name="f1" action="outlets_init.php"  method="post" >
	<input type="text" class="easyui-datebox" id="bt" name="bt" value=<?php echo date('Y-m-d',strtotime('-7 day'))?>>
	--to--<input type="text" class="easyui-datebox" id="et" name='et' value=<?php echo date('Y-m-d',time())?>>
	<input type="button" id="but"  value="go"  >
	</form>
	<br>
	<script >
jQuery(document).ready(function(){
    $('#but').click(function(){  	
    $('#xxoo').datagrid('reload',{st:$('#bt').datebox('getValue'),et:$('#et').datebox('getValue')});
     });

});
</script>
[/quote] alert能正确弹出$('#bt').datebox('getValue')的值,是不是传到后台的过程有问题?
飞舞的锄头 2014-02-26
  • 打赏
  • 举报
回复
引用 1 楼 showbo 的回复:
点击查询的时候再执行
$('#xxoo').datagrid('reload',{st:$('开始日期选择器').datebox('getValue'),et:$('结束日期选择器').datebox('getValue')});
你的应该是datebox组件,如果不行改成对应的组件名称
改成这样后,显示重新加载数据,但显示的内容却没变
<form name="f1" action="outlets_init.php"  method="post" >
	<input type="text" class="easyui-datebox" id="bt" name="bt" value=<?php echo date('Y-m-d',strtotime('-7 day'))?>>
	--to--<input type="text" class="easyui-datebox" id="et" name='et' value=<?php echo date('Y-m-d',time())?>>
	<input type="button" id="but"  value="go"  >
	</form>
	<br>
	<script >
jQuery(document).ready(function(){
    $('#but').click(function(){  	
    $('#xxoo').datagrid('reload',{st:$('#bt').datebox('getValue'),et:$('#et').datebox('getValue')});
     });

});
</script>
Go 旅城通票 2014-02-26
  • 打赏
  • 举报
回复
点击查询的时候再执行
$('#xxoo').datagrid('reload',{st:$('开始日期选择器').datebox('getValue'),et:$('结束日期选择器').datebox('getValue')});
你的应该是datebox组件,如果不行改成对应的组件名称

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧