Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.
This repository was archived by the owner on May 14, 2022. It is now read-only.

A few troubles with a collection field #10

@wtfred

Description

@wtfred

Hi Chad,

I got 2 problems trying to list an entity with a many to many, or one to many relation.

First thing : let's say i have a customer who can have orders. If i want to list my customers and their orders, according to http://datatables.net/ref#mRender
i'll have to do something like that :

"aoColumns": [
      { "mData": "id" },
      { "mData": "name" },
      {
        "mData": "orders",
        "mRender": "[, ].id"
      }
    ]

But with the bundle, "orders" is not recognize as an association :

Field 'Orders' not found
Stack Trace
in ...../vendor/lankit/datatables-bundle/LanKit/DatatablesBundle/Datatables/Datatable.php at line 298

So i'll have to use "orders.id" instead, but then datatables won't be able to use the mRender collection notation because in the json, there is no "orders.id"

"orders":[{"id":1},{"id":2}]

So i'll have to do something like that (have to use "full" because "data" is empty) :

"mRender": function ( data, type, full ) {
                    var text = "";
                    for(index in full.orders) {
                        if(full.orders[index].id != undefined ) {
                            text += full.orders[index].id + ", ";
                        }
                    }
                    return text.substring(0, text.length -2 );

                }

It's not that important as we can find an alternative way to do what we want, but maybe you can add an option so we can say when a field is a actually an association ?

Second thing is more annoying, when i got my list, the "iTotalDisplayRecords" seems to count the "orders" instead of the "customers"

Once again, thanks for your work :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions