Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

TypeError: data is undefined #20

Closed
LucieWallee opened this issue Jul 10, 2018 · 1 comment
Closed

TypeError: data is undefined #20

LucieWallee opened this issue Jul 10, 2018 · 1 comment

Comments

@LucieWallee
Copy link

Hi,
I am trying to reproduce the example that you given.
I have this code :
`

<script type="text/javascript" src='{{ asset('js/DataTables/media/js/jquery.js') }}'></script>

<script type="text/javascript" src='{{ asset('js/DataTables/media/js/jquery.dataTables.min.js') }}'></script>

<script type="text/javascript" src='{{ asset('js/dataTables.treeGrid/dataTables.treeGrid.js') }}'></script>

<script>
    var columns = [
        {
            title: '',
            target: 0,
            className: 'treegrid-control',
            data: function (item) {
                if (item.children) {
                    return '<span>+</span>';
                }
                return '';
            }
        },
        {
            title: 'Name',
            target: 1,
            data: function (item) {
                return item.name;
            }
        },
        {
            title: 'Position',
            target: 2,
            data: function (item) {
                return item.position;
            }
        },
        {
            title: 'Office',
            target: 3,
            data: function (item) {
                return item.office;
            }
        },
        {
            title: 'Extn.',
            target: 4,
            data: function (item) {
                return item.extn;
            }
        },
        {
            title: 'Start date',
            target: 5,
            data: function (item) {
                return item.start;
            }
        },
        {
            title: 'Salary',
            target: 6,
            data: function (item) {
                return item.salary;
            }
        }
    ];

    $('#example').DataTable({
        'columns': columns,
        'ajax': "{{ asset('js/arrays.json') }}",
        'treeGrid': {
            'left': 10,
            'expandIcon': '<span>+</span>',
            'collapseIcon': '<span>-</span>'
        }
    });
</script>

`

And my file arrays.json contains is ine the same format of your example.

So in my dispplay I have that :
image

My problem is, when I click on "+" or "-" I have this message in my console :
image

" [Afficher/Masquer les détails du message.] TypeError: data is undefined[En savoir plus] dataTables.treeGrid.js:140:1
fnConstruct/<
http://localhost/gestion_MKT/web/js/dataTables.treeGrid/dataTables.treeGrid.js:140:1
dispatch
http://localhost/gestion_MKT/web/js/DataTables/media/js/jquery.js:3:12392
add/r.handle
http://localhost/gestion_MKT/web/js/DataTables/media/js/jquery.js:3:9156
"

I hope you cna help me to understand why it doesn't work.

Thank you.

@homfen
Copy link
Owner

homfen commented Jul 30, 2018

I have fixed it.

@homfen homfen closed this as completed Jul 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants