To All,

I just did all the cases you suggested on my application.
This code is the customer listing.

May be it's not "the diamond" of codes but it's my own as the knowledge I have now.

Maybe it can help you and others !

Nuno

Dipl.-Ing. Werner Riegler wrote:

Hi there,

where can I find an example of how to query larg lists in CSP

I mean query just a piece of the list after the other

with a nice next and previous button... ?


I think I need a cursor and remember the row count... but I hope there is already a working example out there ?

by the way - how to sort the list by selecting a column header would be
extra nice ...

brg
werner



--------------070200050307060301020805 Content-Type: text/html; charset=ISO-8859-1; name="ClienteList.csp" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="ClienteList.csp"

<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../Style.css" rel="stylesheet" type="text/css">
<TITLE>   Lista de Clientes </TITLE>
</HEAD>

<BODY>

<csp:class INSERTBROKERAPPLET>
<csp:if condition='%request.Get("HEADER")=0'>
        <!-- Do Nothing -->
<csp:else>
        <csp:include Page="../Topo.csp">
</csp:if>

<table width="100%" border="0" cellspacing="0" cellpadding="4" valign='top'>
   <td width="100%" valign="top">
        
        <script language="cache" runat="server">
        
        // Procura preferencias do Utilizador
        // PageSize=#Linhas/Pagina
        
        //Here I'll get page size according to user preferences.
        // Now It's hardcoded

        Set PageSize=20
        
        set WC=""
        set OB=""
        if ($l(%request.Get("Order"))>0) {
                set OB=" ORDER BY "_%request.Get("Order")
        } else {
                set OB=""
        }
        if (%request.Get("Activo")) {
                Set WC=" WHERE Activo=1"
        }
        Set rs=##class(%ScrollableResultSet).%New()
        Set SQL="SELECT ID, Numero, Nome as Cliente, Territorio->Descricao as 
Territorio,Responsavel->Empregado->Iniciais as Comercial, TotalCompras, TotalMargem  FROM 
ECOM.Cliente "_WC_OB
        //w SQL
        //q
        Do rs.Prepare(SQL)
        Do rs.Execute()
        
        Set Total=rs.Count()
        Set TotalPages=Total\PageSize+1
        //w Total,"-",PageSize,"-",TotalPages,!
        
        if (rs.Count() > 0) {
                Set Page=1
                if (%request.Get("Page")>0) {
                        Set Page=%request.Get("Page")
                }
                &html<
                        <table border=0 name='Tabela' style='font-family: 
Arial,Helvetica,sans-serif; font-size:12px;' valign='top' cellpadding=1 cellspacing=1>
                        <tr class='THeader' align=center style='border-style:ridge;'>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=Numero")#'">N�mero</td>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=Nome")#'">Cliente</td>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=Territorio")#'">Territ�rio</td>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=Comercial")#'">Comercial</td>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=TotalCompras+DESC")#'">Total 
Compras</td>
                        <td class='THeader' 
OnClick="self.document.location='#(%request.URL_"?Order=TotalMargem")#'">Total Margem</td>
                        <td class='THeader'>Projectos<br>em Curso</td>
                        </tr>
                        >

                        //Here you tell to print the page according to preferences
                        d ..PrintPage(Page)
                                        &html<
                <tr>
                <td>
                <TABLE><TR>
                <TD><a href="#(%request.URL)#?Page=1"><img src='../images/go_fb.gif' 
border="0"></a></TD>
                <TD>
                >
                w "<a href='"_%request.URL_"?Page="_$s(Page>1:Page-1, 1:1)_"'>",!
                &html<<img src='../images/go_back.gif' border="0"></a></TD>
                <TD>&nbsp;</TD>
                <TD>
                >
                w "<a href='"_%request.URL_"?Page="_$s(Page<TotalPages:Page+1, 
1:TotalPages)_"'>",!
                &html<<img src='../images/go_forward.gif' border="0"></a></TD>
                <TD><a href="#(%request.URL)#?Page=#(TotalPages)#"><img src='../images/go_ff.gif' 
border="0"></a></TD>
                </TR>
                </TABLE>
                </td>
                <td>Pag. #(Page)#
                /#(TotalPages)#
                </td>
                </tr>
                >

        } else {
                w "No Records",!
        }
        Do rs.Close()
        
        </script>
        </table>
        
<script language="Cache" Method="PrintPage" arguments="page:%Integer" 
returntype="%Boolean">
        set topreg=(page*PageSize)-PageSize
        set rs.CurrRow=topreg
                Set linha=0
                While rs.Next() {
                        if linha < PageSize {
                        Set linha=linha+1
                        Set c=##class(ECOM.Cliente).%OpenId(rs.Data("ID"))
                &html<
                        <tr CLASS='#($S(linha#2:"DarkRow",1:"LightRow"))#' 
onMouseOver="oldClassName=className;className='HighlightRow';" onMouseOut="className=oldClassName;" 
valign=middle>
                        <td class='fnumber'>#(rs.Data("Numero"))#</TD>
                        <td class='ftext'>
                        <a 
href='#(..Link("../Clientes/Cliente.csp?OBJID="_rs.Data("ID")))#'>#(rs.Data("Cliente"))#</a>
                        </td>
                        <td class='ftext'>#(rs.Data("Territorio"))#</TD>
                        <td class='ftext'>#(rs.Data("Comercial"))#</TD>
                        <td class='fnumber'>#($fn(rs.Data("TotalCompras"),".",2))# 
&euro;</TD>
                        <td class='fnumber'>#($fn(rs.Data("TotalMargem"),".",2))# 
&euro;</TD>
                        <td class='fnumber'>#(c.Projectos.Count())#</TD>
                        >
                        }
                }
        Quit 1
</script>

</BODY>
</HTML>

--------------070200050307060301020805--




Reply via email to