Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removes dojango dependency.

Adds support for "lazy reversed" urls (see README file).
  • Loading branch information...
commit 2b2bea1f1858025da1c8a501a36ad86b087dc639 1 parent 63d3dc0
Jonatan Alexis Anauati authored
Showing with 14 additions and 10 deletions.
  1. +1 −2  README
  2. +13 −8 jqgrid.py
View
3  README
@@ -10,7 +10,6 @@ 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+]
@@ -22,7 +21,7 @@ warned!
class ExampleGrid(JqGrid):
model = SomeFancyModel # could also be a queryset
fields = ['id', 'name', 'desc'] # optional
- url = reverse('grid_handler')
+ url = reverse_lazy('grid_handler')
caption = 'My First Grid' # optional
colmodel_overrides = {
'id': { 'editable': False, 'width':10 },
View
21 jqgrid.py
@@ -34,8 +34,12 @@
from django.utils import simplejson as json
from django.utils.encoding import smart_str
from django.http import Http404
-from util.json import json_encode
+from dojango.util import json
+from django.core.serializers.json import DjangoJSONEncoder
+def json_encode(data):
+ encoder = DjangoJSONEncoder()
+ return encoder.encode(data)
class JqGrid(object):
queryset = None
@@ -187,12 +191,13 @@ def paginate_items(self, request, items):
def get_json(self, request):
paginator, page, items = self.get_items(request)
- return json_encode({
- 'page': page.number,
- 'total': paginator.num_pages,
- 'rows': items,
- 'records': paginator.count
- })
+ data={
+ 'page': int(page.number),
+ 'total': int(paginator.num_pages),
+ 'rows': [obj for obj in items],
+ 'records': int(paginator.count),
+ }
+ return json_encode(data)
def get_default_config(self):
config = {
@@ -220,7 +225,7 @@ def get_default_config(self):
return config
def get_url(self):
- return self.url
+ return str(self.url)
def get_caption(self):
if self.caption is None:
Please sign in to comment.
Something went wrong with that request. Please try again.