wrapping long text lengths in grid/smartgrid

瀏覽次數:834 次
跳到第一則未讀訊息

stefaan

未讀,
2011年9月29日 下午4:00:362011/9/29
收件者:web2py-users
I was wondering about grid/smartgrid: currently we can use
maxtextlength=XXX to indicate the max length of a column. If the real
length is longer than XXX, the text is chopped at a suitable length
and "..." is added to it.
If you configure a long maxtextlength, at least with the default
template the column as displayed becomes very wide
Is it somehow possible instead to configure long maxtextlengths and
then have the text wrap at some column?

And related to this: Instead of having long maxtextlength and
wrapping, I could also enable the "View" button, but then I get to see
too many details (certain table columns I don't think are worth
displaying.) Can I customize the fields that are shown by clicking the
"View" button?

Stefaan Himpe

未讀,
2011年9月30日 下午3:26:502011/9/30
收件者:web...@googlegroups.com
A partial reply to my own questions:

> I was wondering about grid/smartgrid: currently we can use
> maxtextlength=XXX to indicate the max length of a column. If the real
> length is longer than XXX, the text is chopped at a suitable length
> and "..." is added to it.
> If you configure a long maxtextlength, at least with the default
> template the column as displayed becomes very wide
> Is it somehow possible instead to configure long maxtextlengths and
> then have the text wrap at some column?

I still have no idea here.

> And related to this: Instead of having long maxtextlength and
> wrapping, I could also enable the "View" button, but then I get to see
> too many details (certain table columns I don't think are worth
> displaying.) Can I customize the fields that are shown by clicking the
> "View" button?

Yes! By defining the database table Fields as writable=False and
readable=False.

Bruno Rocha

未讀,
2011年9月30日 晚上11:28:272011/9/30
收件者:web...@googlegroups.com
grid should have a truncate parameter.

Johann Spies

未讀,
2011年10月3日 凌晨2:45:442011/10/3
收件者:web...@googlegroups.com
On 1 October 2011 05:28, Bruno Rocha <rocha...@gmail.com> wrote:
grid should have a truncate parameter.

It seems that there is none at the moment.  I got

TypeError: grid() got an unexpected keyword argument 'truncate'


when trying

form = SQLFORM.grid(query, columns = columns,deletable = False,
                             orderby = db.akb_articles.title,  maxtextlength = 40,
                             truncate = 150
                            )

Regards
Johann
--
 May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord!  His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence.
                                                    2 Pet. 1:2b,3a

David Marko

未讀,
2011年10月3日 清晨6:50:282011/10/3
收件者:web...@googlegroups.com
Here is the complete signature of grid method from source.... there is really no truncate param.

  def grid(query,
             fields=None,
             field_id=None,
             left=None,
             headers={},
             columns=None,
             orderby=None,
             searchable=True,
             sortable=True,
             paginate=20,
             deletable=True,
             editable=True,
             details=True,
             selectable=None,
             create=True,
             csv=True,
             links=None,
             upload = '<default>',
             args=[],
             user_signature = True,
             maxtextlengths={},
             maxtextlength=20,
             onvalidation=None,
             oncreate=None,
             onupdate=None, 
             ondelete=None,
             sorter_icons=('[^]','[v]'),
             ui = 'web2py',
             showbuttontext=True,
             _class="web2py_grid",             
             formname='web2py_grid',
            ):

Massimo Di Pierro

未讀,
2011年10月3日 下午2:02:212011/10/3
收件者:web2py-users
maxtextlengths={'tablename.fieldname':20}, # per field
maxtextlength=20, # default

Johann Spies

未讀,
2011年10月5日 凌晨2:26:492011/10/5
收件者:web...@googlegroups.com
On 3 October 2011 20:02, Massimo Di Pierro <massimo....@gmail.com> wrote:
            maxtextlengths={'tablename.fieldname':20},  # per field
            maxtextlength=20,  # default


It would be nice to have a possibility to wrap text in a column.

Anthony

未讀,
2011年10月5日 清晨7:37:392011/10/5
收件者:web...@googlegroups.com
I think if you specify a much longer maxtextlength, the text will ultimately wrap, but it may cause the column to be much wider than you want. Maybe all the th's and td's should include column-specific classes so we can use CSS to control the width and other attributes of each column.

Anthony

rāma

未讀,
2017年7月24日 凌晨2:04:192017/7/24
收件者:web2py-users
Still no solution?

Anthony

未讀,
2017年7月25日 上午11:17:142017/7/25
收件者:web2py-users
On Monday, July 24, 2017 at 2:04:19 AM UTC-4, rāma wrote:
Still no solution?

The grid now includes a <colgroup> element with <col> elements like the following:

<col id="tablename-fieldname" data-column="1">

So, you can use CSS rules to control the width of columns based on field names or column numbers.

Anthony

回覆所有人
回覆作者
轉寄
0 則新訊息