Just turn it off after you're done:

db.table.field.represent = lambda v: v[:10] + '...'
grid = webgrid.WebGrid(...)
output = grid()
db.table.field.represent = None

Also you can do:
def shorten_field(r,fieldtype, row):
    if fieldtype=='datarow':
        find your field and shorten it
grid.row_created = shorten_field


On Jun 8, 10:40 am, Julius Minka <[email protected]> wrote:
> Thanks for your response,
> I know, but that changes it everythere, even if I display just one
> record on the page (read of crud).
> I need to shorten the value of the field only in the grid, so that the
> grid is not too wide.
>
> V Utorok, 8. jún 2010 o 08:28 -0700, mr.freeze napísal(a):
>
> > WebGrid uses the represent function to display your field. You can do:
> > db.table.field.represent = lambda v: v[:10] + '...'
>
> > On Jun 8, 10:11 am, Julius Minka <[email protected]> wrote:
> > > The default Webgrid doesn't have a separate div for a field.
> > > Is CSS identification only way to access/change the value?
>
> > > I tried this, it doesn't work:
>
> > > tmp=grid()[0][line][9+activity][0][0:10]  #this works
> > > grid()[0][line][9+activity]['_value']=tmp  #this doesn't
>
> > > V Utorok, 8. jún 2010 o 06:20 -0700, mdipierro napísal(a):
>
> > > > yes
>
> > > > form.element('div#id.class')['_value']=45
>
> > > > On Jun 8, 7:46 am, Julius Minka <[email protected]> wrote:
> > > > > Can this be used to modify a value of an element?
> > > > > I remember I have tried in the past and I failed. The goal was to
> > > > > display just first 10 characters of longer field in the WebGrid by
> > > > > Mr.Freeze.
>
> > > > > Julius
>
> > > > > V Pondelok, 7. jún 2010 o 23:32 -0700, annet napísal(a):
>
> > > > > > Massimo,
>
> > > > > > Indeed it was easier to use form.element(...), thanks for providing 
> > > > > > me
> > > > > > with this solution.
>
> > > > > > Annet.
>
> > > > > > On Jun 7, 8:13 pm, mdipierro <[email protected]> wrote:
> > > > > > > form[0] #table
> > > > > > > form[0][21] # 22nd row
> > > > > > > form[0][21][1] #  second column of above row
> > > > > > > form[0][21][1].insert(0,H4('Text'))
>
> > > > > > > but it should be easier to do
>
> > > > > > > form.element('input[name=xxx]').parent.insert(0,H4('Text'))
>
> > > > > > > where 'xxx' is the name of the field variable.
>
> > > > > > > On Jun 7, 4:24 am, annet <[email protected]> wrote:
>
> > > > > > > > I am using this:
>
> > > > > > > > form[0].insert(21,TR(H4('Text')))
>
> > > > > > > > to insert headers between rows. The header is being inserted in 
> > > > > > > > the
> > > > > > > > first column of the form. I would like to insert an explanatory 
> > > > > > > > text
> > > > > > > > into the second column of a particular row, is that possible 
> > > > > > > > using
> > > > > > > > this syntax, if so, what is the correct syntax.
>
> > > > > > > > Kind regards,
>
> > > > > > > > Annet.

Reply via email to