jqgrid库周围的tosca小部件包装器

tw.jqgrid的Python项目详细描述


Detailed Documentation

tw.jqgrid文档

tw.jqmultiselect是jquery grid插件的tosca小部件包装器
可在此处找到:

http://www.trirand.com/blog/

与此软件包一起发布的版本是3.8.1

Use as a grid

in the view controller

from tw.jqgrid import JqGrid
colNames = ['ID','Title', 'Synopsis']
colModel = [
            {'name':'id', 'index':'id', 'width':20, 'align':'right'},
            {'name':'title', 'index':'title','width':100, 'align':'left'},
            {'name':'synopsis', 'index':'synopsis','width':580, 'align':'left', 'sortable':False},
           ]
search_options = {
      "caption": "Search...",
      "Find": "Find",
      "Reset": "Reset",
      "sopt" : ['cn', 'bw'],
      "closeOnEscape":True,
}

navbuttons_options = {
                      "view":False,
                      "edit": False,
                      "add": False,
                      "del": False,
                      "search":True,
                      "refresh":True,
                      }

grid_local = JqGrid('movie_list', url='fetch', caption='Movies',
            colNames=colNames, colModel=colModel,
            rowList=[5,10], rowNum=5,
            sortname='title',
            viewrecords=True,
            width='auto',
            height='auto',
            shrinkToFit=True,
            search_options = search_options,
            navbuttons_options = navbuttons_options,
)


class MoviesController(BaseRestController):

    @expose('project.templates.movies.get_all')
    def get_all(self):
        pylons.c.grid = grid_local
        return dict(page='all movies')

in the template

${tmpl_context.grid()}

现在要传送数据,我们需要一个控制器:

from math import ceil

@expose('json')
def fetch(self, page=1, rows=10, sidx=1, sord='asc', _search='false',\
          searchOper=u'', searchField=u'', searchString=u'', **kwargs):
    offset = (int(page)-1) * int(rows)
    q = Movie.query
    search_bool = eval(_search.capitalize())
    if (search_bool):
        field = str(searchField)
        field_attr = getattr(Movie, field)
        if searchOper == u'cn':
            q = medias_q.filter(field_attr.contains(searchString))
        if searchOper == u'bw':
            q = q.filter(field_attr.startswith(searchString))

    result_count = medias_q.count()
    total = int(ceil(result_count / float(rows))) # total nb of pages
    column = getattr(Movie.table.c, sidx)
    movies = q.order_by(getattr(column,sord)()).offset(offset).limit(rows)
    rows = [{'id'  : movie.id,
             'cell': [movie.id,  '<a href="/medias/%s/">%s</a>' % (movie.id, movie.title),
                      movie.synopsis]} for movie in movies]
    return dict(page=page, total=total, records=result_count, rows=rows)

注意

这是为长生不老药模型编写的,适合你的需要

design it:

jqgrid的设计依赖于tw.uitheme,平滑的主题是默认的 您可以使用任何其他主题,也可以滚动自己的theme

下面是关于如何做到这一点的代码片段:

from tw.uitheme import lefrog_css, peppergrinder_css
from tw.jqgrid import jqgrid_css, jqgrid_search_css

class CustomGrid(JqGrid):
    css = [peppergrinder_css, jqgrid_css, jqgrid_search_css]

grid_local = CustomGrid(.....

Contributors

主要开发人员
  • nicolas laurance<;nicolas[dot]laurance[at]gmail[dot]com>;

with contributions from

  • 托马斯佩尔顿

Change history

New in 0.3

0.3.2

  • 添加了显示/隐藏折叠按钮的参数
  • 对寻呼机选项的更多控制

0.3.1

  • 添加了可排序参数

0.3

  • 添加了将网格用作jqtreegrid的参数
  • 支持更多活动

New in 0.2

0.2

  • 现在依赖于js lib的3.8.2版本

New in 0.1

0.1b1

  • 添加了编辑URL的参数

0.1a4

  • sortorder的默认值是“asc”
  • 自述文件中的更好示例

0.1a3

  • 添加了sortorder参数以允许设置默认顺序,这要感谢:tuomas peltonen

0.1a2

  • 为子网格添加了参数

0.1a1

  • 增加了对tw.uitheme的设计依赖性

0.1a0

  • 首次发布

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java管道<I/O>流。我可以传递复杂的对象吗?   arraylist使用Java HashMap多类型   注释中不允许从伴随对象分配的java静态最终值   hashmap中的java If构造。打电话   java查找匹配文本中的单词索引   类路径奇怪的Java类路径/类加载器行为   java中检测按钮使用情况的swing方法   使用ExecutorService在Java中执行多线程代码时无法返回,原因是什么?   JAXB将XML文件映射到java类   在JavaSwing应用程序中嵌入Log4j和AOP以记录异常   java在另一个包中委托接口的方法时,如何使委托类成为非公共类?   java如何使用各自的数组ID或值对数组进行排序?   java Fontmetrics stringwidth vs StringLength   hadoop java hdfs api协议缓冲区异常   java将当前数组索引分配给变量以使其递增?   java如何在Emacs中为初学者首次启用自动完成?   java maven 3 webapp没有要运行的测试吗?   java将子类型强制转换为定义为泛型的类型   要运行的java代码。来自jsp页面的exe文件   处理eclipse对java代码的解析?