Hi everyone,
I want to display records in page form that is 10 records in a page. If number of records is more than 10 a next button will be enabled and on click of next it will display the next 10 records and so on.
I have done the coding as below and it is working fine. But every time next is pressed form is submitted and data has to be fetched from database and displayed is there a way of doing this without form submit so that performance is better.
Any help would be appreciated.
Here is a part of the Code:
define variable pv_strtdt as date initial today no-undo.
define variable pv_enddt as date initial today no-undo.
define temp-table tmp_drso_mstr
field tmp_mstr_nbr like drsom_nbr
field tmp_mstr_due like drsom_due
field tmp_mstr_type like drsom_type
field tmp_mstr_value like drsom_value
field tmp_mstr_tons like drsom_tons
index tmp_mstr_nbr is primary tmp_mstr_nbr
index tmp_mstr_due tmp_mstr_due
index tmp_mstr_type tmp_mstr_type.
for each drso_mstr no-lock
where drsom_customer = pvg_mfgid and
drsom_due >= pv_strtdt and
drsom_due <= pv_enddt and
drsom_pro = no break by drsom_type:
accumulate drsom_value (total by drsom_type)
drsom_ton (total by drsom_type).
pv_lncnt = pv_lncnt + 1.
create tmp_drso_mstr.
assign
tmp_drso_mstr.tmp_mstr_nbr = drsom_nbr
tmp_drso_mstr.tmp_mstr_due = drsom_due
tmp_drso_mstr.tmp_mstr_type = drsom_type
tmp_drso_mstr.tmp_mstr_value = drsom_value
tmp_drso_mstr.tmp_mstr_tons = drsom_tons.
end. /* for each drso_mstr no-lock */
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td class="drsvconthead">
Order Number
</td>
<td class="drsvconthead">
Due date
</td>
<td class="drsvconthead">
Order Type
</td>
<td class="drsvconthead">
Value (Rs)
</td>
<td class="drsvconthead">
Tons
</td>
</tr>
<%
pv_pgcnt = 0.
loopdispg:
for each tmp_drso_mstr: /* this logic is for displaying the required page */
if pv_pgcnt ge (pv_lnstart + 9) then leave.
pv_pgcnt = pv_pgcnt + 1.
if pv_pgcnt lt pv_lnstart then next loopdispg.
if pv_lncol then do:
assign
pv_rowcol = "drsvcontdata2"
pv_lncol = no.
end. /* if pv_lncol then do: */
else do:
assign
pv_rowcol = "drsvcontdata1"
pv_lncol = yes.
end. /* else do of if pv_lncol */
%>
<tr class="`pv_rowcol`">
<td><a href="javascript:drsodetview('`tmp_drso_mstr.tmp_mstr_nbr`')">
`tmp_drso_mstr.tmp_mstr_nbr`
</a>
</td>
<td>
`tmp_drso_mstr.tmp_mstr_due`
</td>
<td>
`tmp_drso_mstr.tmp_mstr_type`
</td>
<td align='right'>
`string(tmp_drso_mstr.tmp_mstr_value, ">>,>>>,>>9.99")`
</td>
<td align='right'>
`string(tmp_drso_mstr.tmp_mstr_tons, ">>,>>9.99")`
</td>
</tr>
<%
end. /* for each tmp_drso_mstr: */
if pv_lnstart lt 10 then
pv_prevbut = "disabled".
if (pv_pgcnt ) ge pv_lncnt then
pv_nextbut = "disabled".
%>
<tr>
<td colspan="5" class="drsvcontfoot">
<input `pv_prevbut` class="drsopgbutton" type="button" value="<< Prev" onClick="page_prev();">
Displaying `pv_lnstart` to `pv_pgcnt ` of `pv_lncnt`
<input `pv_nextbut` class="drsopgbutton" type="button" value="Next >>" onClick="page_next();">
</td>
</tr>
</table>
I want to display records in page form that is 10 records in a page. If number of records is more than 10 a next button will be enabled and on click of next it will display the next 10 records and so on.
I have done the coding as below and it is working fine. But every time next is pressed form is submitted and data has to be fetched from database and displayed is there a way of doing this without form submit so that performance is better.
Any help would be appreciated.
Here is a part of the Code:
define variable pv_strtdt as date initial today no-undo.
define variable pv_enddt as date initial today no-undo.
define temp-table tmp_drso_mstr
field tmp_mstr_nbr like drsom_nbr
field tmp_mstr_due like drsom_due
field tmp_mstr_type like drsom_type
field tmp_mstr_value like drsom_value
field tmp_mstr_tons like drsom_tons
index tmp_mstr_nbr is primary tmp_mstr_nbr
index tmp_mstr_due tmp_mstr_due
index tmp_mstr_type tmp_mstr_type.
for each drso_mstr no-lock
where drsom_customer = pvg_mfgid and
drsom_due >= pv_strtdt and
drsom_due <= pv_enddt and
drsom_pro = no break by drsom_type:
accumulate drsom_value (total by drsom_type)
drsom_ton (total by drsom_type).
pv_lncnt = pv_lncnt + 1.
create tmp_drso_mstr.
assign
tmp_drso_mstr.tmp_mstr_nbr = drsom_nbr
tmp_drso_mstr.tmp_mstr_due = drsom_due
tmp_drso_mstr.tmp_mstr_type = drsom_type
tmp_drso_mstr.tmp_mstr_value = drsom_value
tmp_drso_mstr.tmp_mstr_tons = drsom_tons.
end. /* for each drso_mstr no-lock */
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td class="drsvconthead">
Order Number
</td>
<td class="drsvconthead">
Due date
</td>
<td class="drsvconthead">
Order Type
</td>
<td class="drsvconthead">
Value (Rs)
</td>
<td class="drsvconthead">
Tons
</td>
</tr>
<%
pv_pgcnt = 0.
loopdispg:
for each tmp_drso_mstr: /* this logic is for displaying the required page */
if pv_pgcnt ge (pv_lnstart + 9) then leave.
pv_pgcnt = pv_pgcnt + 1.
if pv_pgcnt lt pv_lnstart then next loopdispg.
if pv_lncol then do:
assign
pv_rowcol = "drsvcontdata2"
pv_lncol = no.
end. /* if pv_lncol then do: */
else do:
assign
pv_rowcol = "drsvcontdata1"
pv_lncol = yes.
end. /* else do of if pv_lncol */
%>
<tr class="`pv_rowcol`">
<td><a href="javascript:drsodetview('`tmp_drso_mstr.tmp_mstr_nbr`')">
`tmp_drso_mstr.tmp_mstr_nbr`
</a>
</td>
<td>
`tmp_drso_mstr.tmp_mstr_due`
</td>
<td>
`tmp_drso_mstr.tmp_mstr_type`
</td>
<td align='right'>
`string(tmp_drso_mstr.tmp_mstr_value, ">>,>>>,>>9.99")`
</td>
<td align='right'>
`string(tmp_drso_mstr.tmp_mstr_tons, ">>,>>9.99")`
</td>
</tr>
<%
end. /* for each tmp_drso_mstr: */
if pv_lnstart lt 10 then
pv_prevbut = "disabled".
if (pv_pgcnt ) ge pv_lncnt then
pv_nextbut = "disabled".
%>
<tr>
<td colspan="5" class="drsvcontfoot">
<input `pv_prevbut` class="drsopgbutton" type="button" value="<< Prev" onClick="page_prev();">
Displaying `pv_lnstart` to `pv_pgcnt ` of `pv_lncnt`
<input `pv_nextbut` class="drsopgbutton" type="button" value="Next >>" onClick="page_next();">
</td>
</tr>
</table>