0

I am using a KendoUI grid with serverpaging, I am also using symfony2 in the server side, I have created the routing for handle the request:

_callsList:
    pattern:   /callsList/{id_client}/{take}/{skip}/{page}/{pageSize}
    defaults:  { _controller: StoreBundle:Voip:callsList, take: 20, skip: 0, page: 1, pageSize: 20 }

This is my definition of the grid:

$("#grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: "{{url('_callsList', {'id_client': 3, 'take': 20, 'skip': 0, 'page': 1, 'pageSize': 20})}}"
                            },
                            schema: {
                                model: {
                                    fields: {
                                        callerId: { type: "string" },
                                        calledNumber: { type: "string" },
                                        callStart: { type: "string" },
                                        duration: { type: "string" }
                                    }
                                }
                            },
                            pageSize: 20,
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true,
                            schema: {
                                total : "total",
                                data: "result"
                            }
                        },
                        height: 430,
                        scrollable: true,
                        sortable: true,
                        pageable: {
                            input: true,
                            numeric: false
                        },
                        columns: [
                            { field: "callerId", title: "Numero de Salida", width: "130px" },
                            { field: "calledNumber", title: "Numero de Destino", width: "180px" },
                            { field: "callStart", title: "Fecha", width: "100px" },
                            { field: "duration", title: "Duracion (segundos)", width: "80px" }
                        ]
                    });

The grid loads fine, but when I click on the second page, the URL sent to the server is like this:

http://mydomain.com/app_dev.php/callsList/3/20/0/1/20?take=20&skip=20&page=2&pageSize=20

The Grid is unable to get the second page, and keeps pulling the first 20 results. The right URL should be like this:

http://mydomain.com/app_dev.php/callsList/3/20/20/2/20

As I set on the routing file.

Any idea how to solve this problem???

Thanks!

relez
  • 750
  • 2
  • 13
  • 28

1 Answers1

1

Based on how this lib works i would recommend parsing those options in the ControllerAction itself rather than in the url parameters.

//routing
_callsList:
    pattern:   /callsList/{id_client}/
    defaults:  { _controller: StoreBundle:Voip:callsList }

Then your controller action

public function callsListAction(Request $request, Client $client)
{
    $defaults = array(
        "take" => 20,
        "skip" => 0,
        "page" => 1,
        "pageSize" => 20
    );
    $options = array_merge($defaults, $request->query->all());

    //This should give you your defaults merged with any passed params in $options
    // So /callsList?page=2 will give you:
    // array( "take" => 20,
    //  "skip" => 0,
    //  "page" => 2,
    //  "pageSize" => 20
    // )
}
Chase
  • 9,289
  • 5
  • 51
  • 77