Hello,

do you already know how to do it without Django, e.g with a static dataset?
Because, from the HTML page's view, you will exactly do that.

I don't know JqGrid, but I assume it needs an array of objects, like

gridData = [
    {
        firstColumn: 1,
        secondColumn: "data"
    },
    {
        firstColumn: 2,
        secondColumn:" other data"
    }
];

Generate this array from your querysets inside a <script> block, and there
you go!

It gets a bit trickier if you want to load it dynamically, like loading the
next page of data without reloading the full page, but that's more the
problem of AJAX, not Django.

Best,
Gergely

On Sun, Sep 25, 2016, 23:18 João Rodrigues <joaorod...@gmail.com> wrote:

> I am working on a small online shop with Django 1.9 and JqGrid
>
> Here is a simplification of my models:
>
>     class Addresses(models.Model):
>         address = models.TextField(db_column='ADDRESS', max_length=2000)
>         city = models.CharField(db_column='CITY', max_length=400,
> blank=True, null=True)
>         postal_code = models.CharField(db_column='POSTAL_CODE',
> max_length=200, blank=True, null=True)
>         state = models.CharField(Country, db_column='STATE',
> max_length=400, blank=True, null=True)
>         country = models.ForeignKey(Country, db_column='COUNTRY_ID',
> null=True)
>
>     class Customers(models.Model):
>         name = models.CharField(db_column='NAME', max_length=400)
>         nif = models.CharField(db_column='NIF', max_length=200, null=True,
> blank=True)
>         email = models.CharField(db_column='EMAIL', max_length=255,
> unique=True)
>         mobile_number = models.CharField(db_column='MOBILE_NUMBER',
> max_length=200, blank=True, null=True)
>         phone_number = models.CharField(db_column='PHONE_NUMBER',
> max_length=200, blank=True, null=True)
>         addresses = models.ManyToManyField(Addresses,
> through='CustomerAddresses')
>
>
>     class CustomerAddresses(models.Model):
>         id = models.AutoField(db_column='ID', primary_key=True)
>         address_name = models.CharField(db_column='ADDRESS_NAME',
> max_length=100)
>         customer = models.ForeignKey(Customers)
>         address = models.ForeignKey(Addresses)
>
>
>     class Orders(models.Model):
>         order_number = models.IntegerField(db_column='ORDER_NUMBER',
> unique=True)
>         customer = models.ForeignKey('Customers', db_column='CUSTOMER_ID')
>         payment_date = models.DateTimeField(db_column='PAYMENT_DATE',
> blank=True, null=True)
>         payment_method = models.CharField(db_column='PAYMENT_METHOD',
> max_length=400, blank=True, null=True)
>         delivery_address = models.ForeignKey('Addresses',
> db_column='ORDER_DELIVERY_ADDRESS_ID', related_name='delivery_address',
> blank=True, null=True)
>
>
> I want an edit page for a given Customer to look like this:
>
>
> <https://lh3.googleusercontent.com/-GTeldw1_UTI/V-gvYjADCtI/AAAAAAAADvg/dJ0U3fN6eHQ10tvZIfdLz8Uwdzo5EfdQACLcB/s1600/2016-09-23%2B-%2BEdit%2Bcustomer%2B-%2Bpopulate%2Blists%2Bbelow.png>
>
>
> At the bottom, I want to display grids (JqGrid) inside jQuery tabs.
>
> The Orders grid, should contain all the orders that are associated with
> the current Customer
>
>     queryset = Orders.objects.filter(customer=customer_pk)
>
> Idem, for the Addresses.
>
> As you can see, I successfully created the tabs and grid, BUT the grids
> are not filled with the required data (queryset).
>
> Could you help me understand how I should populate the grids with the data
> I want?
>
> I am sorry if this question is not well explained. I am new in Django. If
> there is something you don't understand, please tell me.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e9b341-f5e3-4010-bb63-78d4bec635ec%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e7e9b341-f5e3-4010-bb63-78d4bec635ec%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUK20%2BGkvhjpozKb3hqeLF6a%3DqmuGKEZkGBXVycThuPQ5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to