AFAIK the grid doesn't support non-integer primary keys. All the ids are
passed around as arguments to have clean urls and dealing with those
arguments as strings is a big issue (imagine /default/index/edit/tablename/*abc
defg ... *it's not even a valid argument ^_^)
On Thursday, October 3, 2013 5:04:56 PM UTC+2, Ari Lion BR Sp wrote:
>
> Hi to All,
>
> I need to work with legacy table, even knowing it's not so recomended.
>
> One of my tables has a String for primarykey.
>
> I have built a SQLFORM.grid
>
> When editing *only numbers* record code (key) - all works fine.
>
> [image: Imagem inline 1]
>
>
> all works fine
>
> [image: Imagem inline 2]
>
> ------------------------------------------------------------
> ------------------------------------------------------------
> ------------------
>
> *but*, when choosing a key which *contains a letter*
> (alphanumeric charachter ), -in bellow case, the 'Y'
>
> [image: Imagem inline 3]
>
> I *get the following error:*:
>
> [image: Imagem inline 4]
> even ticket I do not get.
>
> ------------------------------------------------------------------------------------------------------------------------------------------
> Even when I type the URL , it returns to me *Object not found*:
>
> [image: Imagem inline 6]
> the *Model for * *Artigos* table:
>
> Artigos = db_prodmal.define_table('ARTIGOS',
> Field('COD_ARTIGO','string'),
> Field('NOME', 'string'),
> Field('COMPOSICAO', 'string'),
> .........
> primarykey=['COD_ARTIGO'],
> format='%(NOME)s',
> migrate=False)
>
> the *Controller **:*
>
> *def *artigo_editar():
> # Armazena o ID do artigo
> id_artigo = request.args(0)
> buttons = [TAG.button('Salvar',_type="submit",_class = "btn-success")]
>
> # Form edição do colaborador
> *if *id_artigo == '0':
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,
> buttons =buttons,
> submit_button='Incluir',
> field_id='COD_ARTIGO',
> _id='form_colaborador_editar')
> *else*:
> form_artigo_editar = SQLFORM(db_prodmal.ARTIGOS,id_artigo,
> buttons =buttons,
> submit_button='Alterar',
> _id='form_colaborador_editar',
> field_id='COD_ARTIGO')
>
> *...more code here...*
> *
> *
> *
> *
> * **return *dict(form_artigo_editar=form_artigo_editar, [...other
> returns....])
>
>
>
>
> thanks!
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.