Skip to content

Python JSON serverside render for any JS datagrid library

License

Notifications You must be signed in to change notification settings

fuadarradhi/zarcrender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zarcrender

Python JSON serverside render for any JS datagrid library

def jsondata(request):

    out = {}
    arc = ARCJsonRender({
        'request': request.GET,
        'cursor': connection.cursor(),
        'dbms': dbms.SQL,
        'grid': grid.DATATABLES,
        'keys': keys.QUERYDICT
    })

    # arc.update_config({
    #     'request': request.GET,
    #     'cursor': connection.cursor(),
    #     'dbms': dbms.SQL,
    #     'grid': grid.DATATABLES,
    #     'keys': keys.QUERYDICT
    # })

    arc.set_query(" \
        SELECT * FROM usr_modul_action ma \
        __where__ __order__ __limit_offset__\
        ")
    # arc.set_query("SELECT * FROM usr_modul_action ma")

    def render_nomor(row, line):
        return '{}.'.format(line)

    def render_modul(row, line):
        return '<a href="{}">{}</a>'.format(row.uuid, row.modul)

    def render_action(row, line):
        return row.action

    def render_tombol(row, line):
        return '<a href="{}" class="btn btn-primary btn-md">Ubah</a>'.format(line)

    arc.add_column('nomor', render=render_nomor)
    arc.add_column('uuid', field='ma.uuid', filter=('ma.modul', 'ma.action'))
    arc.add_column('modul', field='ma.modul', render=render_modul)
    arc.add_column('action', render=render_action)
    arc.add_column('tombol', render=render_tombol)

    arc.get_json(out, dumps=False, key=False)

    return JsonResponse(out)

About

Python JSON serverside render for any JS datagrid library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages