A
A
Altyn Bek2016-04-20 14:23:29
MongoDB
Altyn Bek, 2016-04-20 14:23:29

Jtable integration with ExpressJs, anyone had experience with or similar tools?

Good day to all!
Not so long ago I switched to NodeJS and decided to practice, took on a simple task. I started doing it by reading the documentation. . . . etc.
And I ran into a problem, display a list on a table and decided to use jTable.org. only he does not want to work in any way and says:
person-jtable-empty.png
the code on the client:

<script type="text/javascript">
            $(document).ready(function () {
                $('#nationality_table').jtable({

                    title: 'Person table',
                    ajaxSettings: {
                        type: 'POST',
                        dataType: 'json'
                    },
                    actions: {
//                        listAction: '/v1/api/nationality' /*'https://api.github.com/users/hadley/orgs'*/
                        listAction: function (postData) {
                            return $.ajax({
                                    url: '/v1/api/nationality',
                                    type: 'POST',
                                    dataType: 'json',
                                    data: postData,

                                })
                        },
                        createAction: '/GettingStarted/CreatePerson',
//                        updateAction: '/GettingStarted/UpdatePerson',
//                        deleteAction: '/GettingStarted/DeletePerson'
                    },
                    fields: {
                        _id: {
                            key: true,
                            list: false
                        },
                        desc: {
                            title: 'Author Name',
                            width: '40%'
                        }
                    }
                });

//                Load student list from server
                $('#nationality_table').jtable('load');
            });
</script>

I thought the problem is in my JSON response is not valid or .... I check in POSTman and everything says everything is valid.
Response code:
exports.getJson = function(req, res){
    Nationality.find(function(err, items) {
        if(err) res.send(err);
        res.set('Content-Type', 'application/json');
        res.json(items);
    });

}

So far, it accepts both POST and GET requests on /v1/api/nationality, just to be sure))).
Has anyone used it? Or are there any similar solutions? jTable chose the style, honestly. What about js-grid.com?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question