<script type="text/javascript">  
theight=$( document ).height()-50; 
function setdg(){
	$('#dg').datagrid({
		height:theight,
		toolbar:"#toolbar",
		fit:true,
		fitColumns:true,
		singleSelect:true,
		rownumbers:true,		
		pagination:true,
		pageSize:100,
		pageList:[100,200,300,400,500],
		columns:[[  
			{field:'id',title:'id',width:80,hidden:true},
			{field:'tgl',title:'Tanggal'},
			{field:'nama_user',title:'nama_user'},
			{field:'ket',title:'Keterangan',width:200}
		]],
		onBeforeLoad: function (data) {
		  var panel = $(this).datagrid("getPanel");
		  // here is to add the css style
		  panel.css("border","0");
		},
		url: '<?=site_url('log/grid'); ?> '
	});
}

function aksi(cmd){
	var opts = $('#dg').datagrid('options');
	dtdari=$('#dtdari').datebox('getValue');
	dtsampai=$('#dtsampai').datebox('getValue');
	q=$("#q").val();
	
	if (dtdari!="" && dtsampai!=""){
		if (cmd=='cari'){
			$('#dg').datagrid({
				url: '<?=site_url($this->modul.'/aksi/cari')?>',
				queryParams:{
					dtdari:$('#dtdari').datebox('getValue'),
					dtsampai:$('#dtsampai').datebox('getValue'),			
					q:q,
					page:opts.pageNumber,
					rows:opts.pageSize
				}		
			});		
		} else if (cmd=='print'){
			var win = window.open("<?=base_url($this->modul)?>/aksi/cetak?dtdari="+dtdari+"&dtsampai="+dtsampai+"&q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize);
			win.print();
		} else if (cmd=='xls'){
			openurl("<?=base_url($this->modul)?>/aksi/excel?dtdari="+dtdari+"&dtsampai="+dtsampai+"&kd_cmpy=q="+q+"&page="+opts.pageNumber+"&rows="+opts.pageSize);
		}
	}
	
	
}

</script>	