Forum



19:23

24/10/2012

I have a grid that seems to be working properly except that it will not display the last page of data.
This grid is accessingdata on a MS SQL Server, so code might look a llittle different than what you are used to...
Also, work being done in php with codeigniter framework, so its MVC... (kinda)
I have verified in debug that the sql query when requesting the last page is correct, namelly that the $jqstart and $end have the correct values, which are 46 and 60.
I just do not understand why the last page is not displayed in the grid.
Any help would be very much appreciated.
here is my controller...
function ins_maint_viewxx()
{
$pProv = $_GET['prov'];
$page = $this->input->post('page',true);
$limit = $this->input->post('rows',true);
$sidx = $this->input->post('sidx',true);
$sord = $this->input->post('sord',true);
$search = $this->input->post('_search',true);
$sdiag = $this->input->post('diagnosis_code',true);
$sprov = $this->input->post('provider_code',true);
$db = db_connect();
$q = 'select * from insurance_master where provider_code = ?';
$params = array($pProv);
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$x = sqlsrv_query($db, $q, $params, $options);
if ($x === false)
{
echo "Error in query preparation/execution (Controller: setup Function:diag_maint_view <001>).\n";
$err = sqlsrv_errors();
die( print_r( sqlsrv_errors(), true));
}
$count = sqlsrv_num_rows($x);
$err = sqlsrv_errors();
if ( $count > 0 && $limit > 0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page = $total_pages;
$start = $limit*$page - $limit;
if ($start < 0) $start = 0;
$jqstart = $start + 1;
$end = $start + $limit ;
$q_NoSearch = <<<EOD
select * from
( select ROW_NUMBER() OVER (ORDER BY plan_number)
as RowNumber, *
from insurance_master
where provider_code = ?)
as test
where RowNumber BETWEEN $jqstart and $end
EOD;
$q = $q_NoSearch;
$params = array($pProv);
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$x = sqlsrv_query($db, $q, $params, $options);
if ($x === false)
{
echo "Error in query preparation/execution (Model: Function:).\n";
$err = sqlsrv_errors();
die( print_r( sqlsrv_errors(), true));
}
$result = $x;
// we should set the appropriate header information. Do not forget this.
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>".$page."</page>";
$s .= "<total>".$total_pages."</total>";
$s .= "<records>".$count."</records>";
$rec_num = 0;
// be sure to put text data in CDATA
$i = 0;
while($row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC,SQLSRV_SCROLL_ABSOLUTE, 0 + $i) and $i < $limit) {
$rec_num = $rec_num + 1;
$i = $i + 1;
$s .= "<row id='". $row['plan_number'] . "'>";
$s .= "<cell>". $row['plan_number']."</cell>";
$s .= "<cell>". $row['ins_co_name']."</cell>";
$s .= "<cell>". $row['ins_co_addr1']."</cell>";
$s .= "<cell>". $row['ins_co_addr2']."</cell>";
$s .= "<cell>". $row['ins_co_city']."</cell>";
$s .= "<cell>". $row['ins_co_state']."</cell>";
$s .= "<cell>". $row['ins_co_zip']."</cell>";
$s .= "<cell>". $row['ins_co_v_phone']."</cell>";
$s .= "<cell>". $row['ins_co_billcode1']."</cell>";
$s .= "<cell>". $row['ins_co_billcode2']."</cell>";
$s .= "<cell>". $row['financial_class']."</cell>";
$s .= "<cell>". $row['provider_no']."</cell>";
$s .= "<cell>". $row['payer_id']."</cell>";
$s .= "<cell>". $row['follow_up_default']."</cell>";
$s .= "<cell>". $row['claim_filing_indicator']."</cell>";
$s .= "</row>";
}
$s .= "</rows>";
echo $s; // send data to jqgrid
} // end ins_maint_viewxx
and here is my view...
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo "$base$css"?>"</link>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo "$base"?>js/themes/redmond/jquery-ui.custom.css"></link>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo "$base"?>js/jqgrid/css/ui.jqgrid.css"></link>
<script src="<?php echo "$base"?>js/jquery.min.js" type="text/javascript"></script>
<script src="<?php echo "$base"?>js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="<?php echo "$base"?>js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="<?php echo "$base"?>js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
</head>
<body>
<div id="header"> <?php $this->load->view('site_header'); ?> </div>
<form name="ins_maint_view" id="ins_maint" action="" method="post">
</form>
<script type="text/javascript">
$(function() {
$("#list").jqGrid({
url:'ins_maint_viewxx?prov=<?php echo $_POST['provider']?>',
editurl:'ins_maint_editxx?prov=<?php echo $_POST['provider']?>',
datatype: 'xml',
mtype: 'POST',
colNames:['Plan #', 'Name', 'Addr1', 'Addr2', 'City', 'State', 'Zip', 'V-Phone', 'Bill Code1', 'Bill Code2', 'Fin Class', 'Prov #', 'Payer ID', 'FU Days', 'Filing Ind'],
colModel :[
{name:'plan_number',
index: 'plan_number',
width:50,
search:false
},
{name:'ins_co_name',
index: 'ins_co_name',
width:200,
editable:true,
search:false,
formoptions: { rowpos:1, colpos:1 }
},
{name:'ins_co_addr1',
index:'ins_co_addr1',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:2, colpos:1 }
},
{name:'ins_co_addr2',
index:'ins_co_addr2',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:2, colpos:2 }
},
{name:'ins_co_city',
index:'ins_co_city',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:3, colpos:1 }
},
{name:'ins_co_state',
index:'ins_co_state',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:3, colpos:2 }
},
{name:'ins_co_zip',
index:'ins_co_zip',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:3, colpos:3 }
},
{name:'ins_co_v_phone',
index:'ins_co_v_phone',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:4, colpos:1 }
},
{name:'ins_co_billcode1',
index:'ins_co_billcode1',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:5, colpos:1 }
},
{name:'ins_co_billcode2',
index:'ins_co_billcode2',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:5, colpos:2 }
},
{name:'financial_class',
index:'financial_class',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:6, colpos:1}
},
{name:'provider_no',
index:'provider_no',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:7, colpos:1 }
},
{name:'payer_id',
index:'payer_id',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:7, colpos:2 }
},
{name:'follow_up_default',
index:'follow_up_default',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:8, colpos:1 }
},
{name:'claim_filing_indicator',
index:'claim_filing_indicator',
editable:true,
hidden:true, editrules: { edithidden: true },
formoptions: { rowpos:8, colpos:2 }
},
],
width: 700, // width in pixels
height: 340,
pager: '#pager',
rowNum: 15,
rowList: [10,20,30],
sortname: 'plan_number',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'Insurance Master'
});
jQuery("#list").jqGrid('navGrid','#pager',{
edit:true,
add:false,
del:false,
search:false,
refresh:true},
{width:750, height:350} ); // width of edit form
jQuery("#list").jqGrid('filterToolbar');
});
</script>
<table id="list"><tr><td/></tr></table>
<div id="pager"></div>
<p>
<a href="<?php echo "$base"?>index.php/setup">Return to Menu</a>
</p>
<div id="footer">
<?php $this->load->view('site_footer'); ?>
</div>
</body>
</html>
Most Users Ever Online: 715
Currently Online:
44 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66