當前位置: 首頁>>代碼示例>>Python>>正文


Python HTML.th方法代碼示例

本文整理匯總了Python中webhelpers2.html.HTML.th方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.th方法的具體用法?Python HTML.th怎麽用?Python HTML.th使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webhelpers2.html.HTML的用法示例。


在下文中一共展示了HTML.th方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: filtering_table_row

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import th [as 別名]
 def filtering_table_row(self, col):
     extra = getattr(col.filter, 'html_extra', {})
     return _HTML.tr(
         _HTML.th(self.filtering_col_label(col), class_='filter-label')
         + _HTML.td(self.filtering_col_op_select(col), class_='operator')
         + _HTML.td(
             _HTML.div(self.filtering_col_inputs1(col), class_='inputs1')
             + _HTML.div(self.filtering_col_inputs2(col), class_='inputs2')
         ),
         # Added _filter to address CSS collision with Bootstrap
         # Ref: https://github.com/level12/webgrid/issues/28
         class_=col.key + '_filter',
         **extra
     )
開發者ID:level12,項目名稱:webgrid,代碼行數:16,代碼來源:renderers.py

示例2: th_sortable

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import th [as 別名]
def th_sortable(current_order, column_order, label, url,
    class_if_sort_column="sort", class_if_not_sort_column=None, 
    link_attrs=None, name="th", **attrs):
    """<th> for a "click-to-sort-by" column.

    Convenience function for a sortable column.  If this is the current sort
    column, just display the label and set the cell's class to
    ``class_if_sort_column``.
    
    ``current_order`` is the table's current sort order.  ``column_order`` is
    the value pertaining to this column.  In other words, if the two are equal,
    the table is currently sorted by this column.

    If this is the sort column, display the label and set the <th>'s class to
    ``class_if_sort_column``.

    If this is not the sort column, display an <a> hyperlink based on
    ``label``, ``url``, and ``link_attrs`` (a dict), and set the <th>'s class
    to ``class_if_not_sort_column``.  
    
    ``url`` is the literal href= value for the link.  Pylons users would
    typically pass something like ``url=h.url_for("mypage", sort="date")``.

    ``**attrs`` are additional attributes for the <th> tag.

    If you prefer a <td> tag instead of <th>, pass ``name="td"``.

    To change the sort order via client-side Javascript, pass ``url=None`` and
    the appropriate Javascript attributes in ``link_attrs``.

    Examples:

    >>> sort = "name"
    >>> th_sortable(sort, "name", "Name", "?sort=name")
    literal(u'<th class="sort">Name</th>')
    >>> th_sortable(sort, "date", "Date", "?sort=date")
    literal(u'<th><a href="?sort=date">Date</a></th>')
    >>> th_sortable(sort, "date", "Date", None, link_attrs={"onclick": "myfunc()"})
    literal(u'<th><a onclick="myfunc()">Date</a></th>')
    """
    from webhelpers2.html import HTML
    if current_order == column_order:
        content = label
        class_ = class_if_sort_column
    else:
        link_attrs = link_attrs or {}
        content = HTML.a(label, href=url, **link_attrs)
        class_ = class_if_not_sort_column
    return HTML.th(content, class_=class_, **attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:51,代碼來源:tags.py

示例3: table_th

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import th [as 別名]
 def table_th(self, col):
     label = col.label
     if self.grid.sorter_on and col.can_sort:
         url_args = {}
         url_args['dgreset'] = None
         url_args['sort2'] = None
         url_args['sort3'] = None
         cls = None
         if self.grid.order_by and len(self.grid.order_by) == 1:
             current_sort, flag_desc = self.grid.order_by[0]
             if current_sort == col.key:
                 cls = 'sort-' + ('desc' if flag_desc else 'asc')
             if current_sort != col.key or flag_desc:
                 url_args['sort1'] = col.key
             else:
                 url_args['sort1'] = '-{0}'.format(col.key)
         else:
             url_args['sort1'] = col.key
         label = _HTML.a(
             label,
             href=self.current_url(**url_args),
             class_=cls
         )
     return _HTML.th(label, **col.head.hah)
開發者ID:level12,項目名稱:webgrid,代碼行數:26,代碼來源:renderers.py


注:本文中的webhelpers2.html.HTML.th方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。