Christoph Zwerschke wrote:
Am 14.04.2010 13:25 schrieb jose soares:
gridFields=[ #campi della grid
NewSelectablePagDataGrid.Column(name='specie_codice', title='codice',
> ...
]

class Controller(object):
@tg.expose(template="kid:sicer.BASE.view.templates.edit")
@tg.paginate(var_name='grid_params', max_limit=None, dynamic_limit='limit')
def index(self):
...
)

I just tried your controller and grid with TG 1.1.1 and it is working fine for me with the standard PaginateDataGrid widget, I can sort and paginate, the sorting takes place in the database and there are no errors if there are null columns for the dates.

I suppose you tried without no values at all in the column data_fine in all rows,
in such case there's no error because it compares None with None,
try to insert a date in almost one row and you will see the error.

furthermore, I'm trying to understand how sorting works,

(default_order without minus sign = ORDER BY ASC, rigth?)

@tg.paginate(var_name='grid_params', default_order='specie_cod_gruppo_specie', max_limit=None, dynamic_limit='limit') (no reverse sort)

the first time the grid show this:
http://tg11.sfera.com/specie/

sql: select * from specie order by cod_gruppo_specie asc; (*)

 codice | descrizione | cod_gruppo_specie |        data_fine
--------+-------------+-------------------+--------------------------
 0129   | Bufalino    | 0121              |
 0121   | Bovino      | 0121              |
 0122   | Suino       | 0122              |
 0124   | Ovino       | 0124              |
 0125   | Caprino     | 0124              |
 0137   | Oca         | 0127              |
 0138   | Faraona     | 0127              |
 0139   | Fagiano     | 0127              |
 0126   | Equidi      | 0131              |
 0128   | Coniglio    |                   | Thu 15 Apr 00:00:00 2010
(10 rows)

the first time I click on column 'specie_cod_gruppo_specie' the url becomes like this:

http://tg11.sfera.com/specie/?grid_params_tgp_ordering=specie_cod_gruppo_specie&grid_params_tgp_limit=10&grid_params_tgp_order=specie_cod_gruppo_specie&grid_params_tgp_no=1
Here I expected -
specie_cod_gruppo_specie instead of specie_cod_gruppo_specie, infact the order by is desc
sql:  select * from specie order by cod_gruppo_specie desc; (*)


 codice | descrizione | cod_gruppo_specie |        data_fine
--------+-------------+-------------------+--------------------------
 0128   | Coniglio    |                   | Thu 15 Apr 00:00:00 2010
 0126   | Equidi      | 0131              |
 0139   | Fagiano     | 0127              |
 0137   | Oca         | 0127              |
 0138   | Faraona     | 0127              |
 0124   | Ovino       | 0124              |
 0125   | Caprino     | 0124              |
 0122   | Suino       | 0122              |
 0129   | Bufalino    | 0121              |
 0121   | Bovino      | 0121              |
(10 rows)

the second time I click on column 'specie_cod_gruppo_specie' the url becomes like this:

http://tg11.sfera.com/specie/?grid_params_tgp_ordering=-specie_cod_gruppo_specie&grid_params_tgp_limit=10&grid_params_tgp_order=specie_cod_gruppo_specie&grid_params_tgp_no=1
Here there's the reverse sign but it sorts with ASC
sfera_tg11=# select * from specie order by cod_gruppo_specie asc;(*)

 codice | descrizione | cod_gruppo_specie |        data_fine
--------+-------------+-------------------+--------------------------
 0129   | Bufalino    | 0121              |
 0121   | Bovino      | 0121              |
 0122   | Suino       | 0122              |
 0124   | Ovino       | 0124              |
 0125   | Caprino     | 0124              |
 0137   | Oca         | 0127              |
 0138   | Faraona     | 0127              |
 0139   | Fagiano     | 0127              |
 0126   | Equidi      | 0131              |
 0128   | Coniglio    |                   | Thu 15 Apr 00:00:00 2010
(10 rows)

(*) paginate sorts the columns with None in a different way from Postgres.

Thank you for your support, Christoph.
j


-- Christoph

(This is what I used as model file:)

specie_table = Table('specie', metadata,
    Column('codice', String(8), primary_key=True),
    Column('descrizione', String(32)),
    Column('data_fine', DateTime, default=datetime.now),
    Column('cod_gruppo_specie', Integer, ForeignKey('gruppo_specie.codice')))

gruppo_specie_table = Table('gruppo_specie', metadata,
    Column('codice', String(8), primary_key=True),
    Column('descrizione', String(32)))

class Specie(object):
    pass

class GruppoSpecie(object):
    pass

mapper(Specie, specie_table)

mapper(GruppoSpecie, gruppo_specie_table,
    properties=dict(
        species=relation(Specie, backref='gruppo_specie')))



-- 
Jose Soares
Sferacarta Net 
Via Bazzanese 69
40033 Casalecchio di Reno
Bologna - Italy
Ph  +39051591054
fax +390516131537
web:www.sferacarta.com

Le informazioni contenute nella presente mail ed in ogni eventuale file allegato sono riservate e, comunque, destinate esclusivamente alla persona o ente sopraindicati, ai sensi del decreto legislativo 30 giugno 2003, n. 196. La diffusione, distribuzione e/o copiatura della mail trasmessa, da parte di qualsiasi soggetto diverso dal destinatario, sono vietate. La correttezza, l’integrità e la sicurezza della presente mail non possono essere garantite. Se avete ricevuto questa mail per errore, Vi preghiamo di contattarci immediatamente e di eliminarla. Grazie.

This communication is intended only for use by the addressee, pursuant to legislative decree 30 June 2003, n. 196. It may contain confidential or privileged information. You should not copy or use it to disclose its contents to any other person. Transmission cannot be guaranteed to be error-free, complete and secure. If you are not the intended recipient and receive this communication unintentionally, please inform us immediately and then delete this message from your system. Thank you.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

Reply via email to