Giter VIP home page Giter VIP logo

django-jqgrid's Introduction

= django-jqgrid =
django-jqgrid aims to make integrating full support for jqgrid as simple as
defining which models you want exposed, while still supporting the more
advanced features.

After unexpected interest, I have decided to provide an early release in the
form as a utility class. This release is not stable or intented for production
use. I will be cleaning up, restructuring (to a more flexible classed generic
handler), and adding documentation/examples soon. Until then, you have been 
warned! 

== Prerequisites ==
  * [http://code.google.com/p/dojango/source/browse/trunk/dojango/util/__init__.py#97 json_encode]
  * [http://www.jquery.com jQuery 1.3+]
  * [http://www.trirand.com/blog/?page_id=6 jqGrid 3.5+]

== Example ==

1. First define your grid somewhere (e.g., grids.py). Only a model or queryset
   and a url are required.
{{{
class ExampleGrid(JqGrid):
    model = SomeFancyModel # could also be a queryset
    fields = ['id', 'name', 'desc'] # optional 
    url = reverse('grid_handler')
    caption = 'My First Grid' # optional
    colmodel_overrides = {
        'id': { 'editable': False, 'width':10 },
    }
}}}

2. Create views to handle requests.
{{{
def grid_handler(request):
    # handles pagination, sorting and searching
    grid = ExampleGrid()
    return HttpResponse(grid.get_json(request), mimetype="application/json")

def grid_config(request):
    # build a config suitable to pass to jqgrid constructor   
    grid = ExampleGrid()
    return HttpResponse(grid.get_config(), mimetype="application/json")

}}}

3. Define urls for those views.
{{{
url(r'^examplegrid/$', grid_handler, name='grid_handler'),
url(r'^examplegrid/cfg/$', grid_config, name='grid_config'),
}}}

4. Configure jgrid to use the defined urls.
{{{
$(function () {
    $.getJSON("{% url grid_config %}", function(data){
        $("#mygrid")
            .jqGrid(data)
            .navGrid('#pager', 
                {add: false, edit: false, del: false, view: true},
        {}, // edit options
        {}, // add options
        {}, // del options 
        { multipleSearch:true, closeOnEscape:true }, // search options 
        { jqModal:false, closeOnEscape:true} // view options 
        );
    });
});
}}}

django-jqgrid's People

Contributors

gerry avatar tubaman avatar

Stargazers

Alex avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.