Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2235 (closed documentation: migrated)

Opened 10 years ago

Last modified 8 years ago

DataGrid and pagination tutorial/reference missing for TG2

Reported by: chrisz Owned by:
Priority: normal Milestone: 2.1 docs
Component: Documentation Version: 2.1
Severity: normal Keywords: datagrid pagination
Cc:

Description

TG 1.0 had some helpful documentation and demo projects for DataGrid and pagination:  http://docs.turbogears.org/1.0/PaginateDecorator

If you search for these keywords in the TG 2.0 docs, you get zero hits. A tutorial and reference documentation on these issues should be part of the TG 2.0 docs.

(Actually DataGrid is now part of tw.forms, but I don't know if/how pagination is even possible with TG2. If it's not possible this should still be mentioned in the docs since it was possible with TG1. Or maybe there are alternative solutions.)

Change History

comment:1 Changed 10 years ago by lszyba1

#Documentation below:

One way to provide links is to send the html markup to actual datagrid column. In a normal situation you would send just a "name":

# data grid
from tw.forms.datagrid import DataGrid

cogbin_grid = [('Package Name',name),
                ('Version','version'),
                ('Summary','summary'),
                ('Author','author'),
                ]

To send the link url you can tell create html link tag with field to include. Below we provide home_page and name to our link:

from genshi import Markup
def get_link(item):
    return Markup("""<a href="%s">%s</a>""" % (item.home_page,item.name))

#data grid
from tw.forms.datagrid import DataGrid

cogbin_grid = [('Package Name',name),
                ('Version','version'),
                ('Summary','summary'),
                ('Author','author'),
                ]


Another use is to create a edit button which would look like this:

from genshi import Markup
def get_link(item):
    return Markup("""<a href="edit/%s">Edit</a>""" % item.id)

comment:2 follow-up: ↓ 3 Changed 10 years ago by lszyba1

Please fix: *To send the link url you can create html link

Is there a way to edit my reply?

comment:3 in reply to: ↑ 2 Changed 10 years ago by chrisz

Replying to lszyba1:

Is there a way to edit my reply?

No, normal users cannot edit. But there is a preview.

If you want to work on that documentation, you should create a new page here:  http://docs.turbogears.org/2.0/RoughDocs

A lot of material can also be taken from here, but it is TG1 specific:  http://docs.turbogears.org/1.0/PaginateDecorator

It would be nice to have a small tutorial again, with a demo project that can be downloaded (the TG1 demo projects for pagination were really good).

The docs should cover datagrid, pagination and combination of both.

It seems pagination is available as a Pylons webhelper, but I don't know how similar it is to TG1 pagination and how well it integrates with TW widgets such as datagrid. TG1 came with "a paginate datagrid" - the docs should show how you can do something like this with TG2.

comment:4 Changed 10 years ago by mramm

  • Milestone changed from 2.0rc1 to 2.0rc2

comment:5 Changed 10 years ago by percious

  • Version changed from 2.0b5 to 2.1
  • Milestone changed from 2.1a1 to 2.1 docs

comment:6 Changed 10 years ago by lukasg

I provided an  initial draft for a TG2 pagination tutorial, and I'm about to update it, but I've got a couple open questions:

  • Should the tutorial continue be based on the  ToscaWidgets example or not?
    • Pros:
      • Limits the amount of different examples used in the docs (Movies, Books, ...) and therefore enables users to re-use their work on a previous tutorial, allowing them to quickly follow some tutorials in order and end up with ONE sophisticated example covering several aspects.
    • Cons:
      • Harder to maintain: (Significant) Changes in the TW example need to be applied to the Pagination tut as well
      • Lots code in the example project that is unrelated to pagination (form handling etc..)
      • Users can't follow along with the tut unless they downloaded or completed the TW example

  • Image links: Should the tutorial address those at all?
    When I first came up with the draft I thought it might be neat to provide some info on this. However, it ended up really cluttering the tutorial with stuff that is in no way related to TG or Pylons, simply HTML+CSS, that's why I'm thinking about throwing that part out alltogether. On the other hand, if using the format tokens $link_previous and $link_next, there's no trivial way to make them use images (CSS class can only be overriden for pager links in general, the separator dots or the current page, but not the first/last next/prev links).
  • Versioning: Do we actively maintain different tutorials for 2.0 and 2.1?
    The zipped example project is functional for 2.1, but when users follow the tutorial, they'll get to the point where 'websetup.py' doesn't exist anymore for 2.1, it's now a directory containing bootstrap.py and schema.py. My current approach would be rewriting the tut for 2.1, and just add a little note explaining what websetup was called in 2.0.

comment:7 Changed 8 years ago by pedersen

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.