Hi
I use this function
 function SeleccionarComun()
        {
            //blockUI.start();
            LimpiarGrilla();

            $timeout(function () {
                vm.dtOptions = DTOptionsBuilder
                .newOptions().withOption('bFilter', false)
                .withOption('stateSave', true)
                .withOption('responsive', false)
                .withOption('order', [])
                .withFnServerData(BuscarOportunidadesPaginadoNivel)
                .withDataProp('data')
                .withOption('serverSide', true)
                .withOption('paging', true)
                .withOption('initComplete', function (setting, data) {
                    //Logic for hide show columns or any conditions 
statement

                    if (vm.nivel == 1)
                    {
                        $('#DatatableID').dataTable().fnSetColumnVis(8, 
false);
                        $('#DatatableID').dataTable().fnSetColumnVis(9, 
false);
                        $('#DatatableID').dataTable().fnSetColumnVis(10, 
false);
                        $('#DatatableID').dataTable().fnSetColumnVis(11, 
false);
                        $('#DatatableID').dataTable().fnSetColumnVis(12, 
false);
                        Cargar();
                    }
                    else
                    {
                        if (vm.nivel == 2) {
                            $('#DatatableID').dataTable().fnSetColumnVis(8, 
true);
                            $('#DatatableID').dataTable().fnSetColumnVis(9, 
true);
                            
$('#DatatableID').dataTable().fnSetColumnVis(10, false);
                            
$('#DatatableID').dataTable().fnSetColumnVis(11, false);
                            
$('#DatatableID').dataTable().fnSetColumnVis(12, false);
                            Cargar();
                        }
                        else {
                            if (vm.nivel == 3) {
                                
$('#DatatableID').dataTable().fnSetColumnVis(8, true);
                                
$('#DatatableID').dataTable().fnSetColumnVis(9, true);
                                
$('#DatatableID').dataTable().fnSetColumnVis(10, true);
                                
$('#DatatableID').dataTable().fnSetColumnVis(11, true);
                                
$('#DatatableID').dataTable().fnSetColumnVis(12, true);
                                Cargar();
                            }
                        }
                    }
                })
                .withOption('createdRow', function (row, data, dataIndex) {

                    if (data.CantidadClientesPreventaCadena == 'Cliente' || 
data.OportunidadesPreventaCadena == 'Oportunidad' ||
                        data.PorcentajeCumplimientoClienteCadena == 'Fase') 
{
                        
                        $('td', row).addClass('header_pagining');
                        $compile(angular.element(row).contents())($scope);
                    }

                })
                .withOption('destroy', true)
                .withPaginationType('full_numbers')
                .withDisplayLength(10);
            }, 500);
        }

This function executes the function:

function BuscarOportunidadesPaginadoNivel(sSource, aoData, fnCallback, 
oSettings) {

            var request = {
                oportunidadesFiltro:
                {
                    Nivel: 0,
                    ListaPreventaIncluir: 
JSON.stringify(vm.ListaPreventaIncluir),
                    ListaPreventaExcluir: 
JSON.stringify(vm.ListaPreventaExcluir),
                    ListaClientesIncluir: 
JSON.stringify(vm.ListaClientesIncluir),
                    ListaClientesExcluir: 
JSON.stringify(vm.ListaClientesExcluir),
                }
            };

            BuscarOportuniadesComun(sSource, aoData, fnCallback, oSettings, 
request);
        }
The last function executes the function:

function BuscarOportuniadesComun(sSource, aoData, fnCallback, oSettings, 
request)
        {
            var fechaActual = new Date();
            var anioActual = fechaActual.getFullYear()

            var draw = aoData[0].value;
            var start = aoData[3].value;
            var length = aoData[4].value;
            var pageNumber = (start + length) / length;

            request.oportunidadesFiltro.Anio = anioActual;
            request.oportunidadesFiltro.IdJefe = idUsuario;

            if (pageNumber != vm.pageNumber || length != vm.tamanioPagina) {

                vm.ListaPreventaIncluir = [];
                vm.ListaPreventaExcluir = [];
                vm.ListaClientesIncluir = [];
                vm.ListaClientesExcluir = [];

                request.Nivel = 1;

                request.oportunidadesFiltro.ListaPreventaIncluir = 
JSON.stringify(vm.ListaPreventaIncluir);
                request.oportunidadesFiltro.ListaPreventaExcluir = 
JSON.stringify(vm.ListaPreventaExcluir);
                request.oportunidadesFiltro.ListaClientesIncluir = 
JSON.stringify(vm.ListaClientesIncluir);
                request.oportunidadesFiltro.ListaClientesExcluir = 
JSON.stringify(vm.ListaClientesExcluir);
            }

            vm.pageNumber = pageNumber;
            vm.tamanioPagina = length;


            request.oportunidadesFiltro.Paginacion =
                {
                    Indice: pageNumber,
                    Tamanio: length
                };

            var promise = 
RptPreventaOportunidadesLiderService.ListarOportunidades(request);

            promise.then(function (resultado) {
                var result = {
                    'draw': draw,
                    'recordsTotal': resultado.data.Total,
                    'recordsFiltered': resultado.data.Total,
                    'data': resultado.data.ListaOportunidades
                };
                blockUI.stop();
                fnCallback(result)

            }, function (response) {
                blockUI.stop();
            });



        }



El sábado, 15 de diciembre de 2018, 0:40:24 (UTC-5), juan aguilar abanto 
escribió:
>
> Hi
> I have a table in angularjs datatable. When I click in some parts in the 
> table I receive information and refresh the table.
> The problem is that the page number changes to 1..
> I would like to keep the same number and size of page when I refresh the 
> table..
>
> [image: Sin título.png]
>
> This is the code which creates the table:
>
> $timeout(function () {
>                 vm.dtOptions = DTOptionsBuilder
>                 .newOptions().withOption('bFilter', false)
>                 .withOption('stateSave', true)
>                 .withOption('responsive', false)
>                 .withOption('order', [])
>                 .withFnServerData(BuscarOportunidadesPaginadoNivel)
>                 .withDataProp('data')
>                 .withOption('serverSide', true)
>                 .withOption('paging', true)
>                 .withOption('destroy', true)
>                 .withPaginationType('full_numbers')
>                 .withDisplayLength(10);
>             }, 500);
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to