tabalinas/jsgrid

Laravel 5 - Push data to the controllers

Open

#990 aperta il 3 gen 2018

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)JavaScript (356 fork)batch import
help wanted

Metriche repository

Star
 (1520 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

I am trying to implement a sample CRUD project of jsgrid on laravel 5.

Problem

I have implemented the controller as the following:

$(function () {

    $("#jsGrid").jsGrid({
        width: "100%",
        height: "400px",
        
        filtering: true,
        inserting: true,
        editing: true,
        sorting: true,
        paging: true,
        autoload: true,

        data: storedTasks,
        controller: {
            loadData: function(filter) {
                console.log("Filter: "+ filter)
                return $.ajax({
                    type: "GET",
                    url: "/tasks/",
                    data: storedTasks
                });
            },
            insertItem: function(item) {
                console.log("item: " + item)
                return $.ajax({
                    type: "POST",
                    url: "/tasks/",
                    data: storedTasks
                });
            },
            updateItem: function(item) {
                return $.ajax({
                    type: "PUT",
                    url: "/tasks/",
                    data: item
                });
            },
            deleteItem: function(item) {
                return $.ajax({
                    type: "DELETE",
                    url: "/tasks/",
                    data: item
                });
            }
        },
        fields: [{
                name: "Name",
                type: "text",
                width: 150,
                validate: "required"
            },
            {
                name: "Created_At",
                type: "text",
                width: 200
            },
            {
                name: "Updated_At",
                type: "text",
                width: 200
            },
            {
                name: "revision_status",
                type: "checkbox",
                title: "Revision Status",
                sorting: false
            },
            {
                type: "control"
            }
        ]
    });
});

My routes in my backend look like the following:

Route::resource('/tasks', 'TaskController'); with the following routes:

+--------+-----------+------------------------------+----------------------+---------------------------------------------------------------+----------------------------------------------+
| Domain | Method    | URI                          | Name                 | Action                                                        | Middleware
                        |
+--------+-----------+------------------------------+----------------------+---------------------------------------------------------------+----------------------------------------------+
|        | GET|HEAD  | api/user                     |                      | Closure                                                       | api,auth:api
                        |
|        | GET|HEAD  | tasks                        | tasks.index          | App\Http\Controllers\TaskController@index                     | web
                        |
|        | POST      | tasks                        | tasks.store          | App\Http\Controllers\TaskController@store                     | web
                        |
|        | GET|HEAD  | tasks/create                 | tasks.create         | App\Http\Controllers\TaskController@create                    | web
                        |
|        | GET|HEAD  | tasks/{task}                 | tasks.show           | App\Http\Controllers\TaskController@show                      | web
                        |
|        | PUT|PATCH | tasks/{task}                 | tasks.update         | App\Http\Controllers\TaskController@update                    | web
                        |
|        | DELETE    | tasks/{task}                 | tasks.destroy        | App\Http\Controllers\TaskController@destroy                   | web
                        |
|        | GET|HEAD  | tasks/{task}/edit            | tasks.edit           | App\Http\Controllers\TaskController@edit                      | web
                        |
+--------+-----------+------------------------------+----------------------+---------------------------------------------------------------+----------------------------------------------+

Any suggestions why no event is fired in the frontend controller or are my backend routes wrong?

I appreciate your reply!

Guida contributor