Ir para conteúdo
Fórum Script Brasil
  • 0

Paginação Flexigrid


JoeJr

Pergunta

Bom dia !

tenho um flexigrid que me retorna alguns dados via XML, porém o mesmo não faz a paginação.

Consigo apenas mudar de página manualmente, direto na Query, onde eu altero o numero da pagina e o LIMIT.

Query :


    $page = 1;
    if (!$rp) $rp = 100;
    
    $start = (($page-1) * $rp);
    
    $limit = "LIMIT $start, $rp";

    $stringSQL        = "select $exibicao from $tabela $Where $orderBy $limit";

 

Flexigrid:

<table class='flexme4' id="flex1" style="display:none"></table>
<script type="text/javascript">


    $(".flexme4").flexigrid({
                url : '/corporativo/servicos/bi/<?php echo $urlRequireAjax; ?>consultaBS.php?id_file=<?php echo $_GET['id_file']; ?>',
                dataType : 'json',
                colModel : [ 
                   <?php 
                       //descobre título das colunas no select montado
                    $elementoExibe = $doc->getElementsByTagName("condicaoExibicao")->item(0)->childNodes;
                    $e="";
                    $a=0;
                    foreach($elementoExibe as $condExibe){
                    
                        $titulo = utf8_decode($condExibe->getAttribute('tituloColuna'));
                        $codigo    = explode("_",$condExibe->tagName);
                        
                        if($a == 0){
                            $e.= "{display: '$titulo', name : '".$codigo[1]."', width : 80, sortable : false, align: 'left'}\r\n";
                        } else {
                            $e.= ",{display: '$titulo', name : '".$codigo[1]."', width : 80, sortable : false, align: 'left'}\r\n";
                        }
                        $a++;
                    }
                        
                        echo $e;
                ?>
                ],
                buttons : [ 
                // {
                //     name : 'Add',
                //     bclass : 'add',
                //     onpress : Example4
                //     }
                //     ,
                //     {
                //         name : 'Edit',
                //         bclass : 'edit',
                //         onpress : Example4
                //     }
                //     ,
                //     {
                //         name : 'Delete',
                //         bclass : 'delete',
                //         onpress : Example4
                //     }
                //     ,
                //     {
                //         separator : true
                //     } 
                ],
                //searchitems : [ 
                // {
                //     display : 'EmployeeID',
                //     name : 'employeeID'
                //     }, {
                //         display : 'Name',
                //         name : 'name',
                //         isdefault : true
                // } 
                //],
                sortname: "<?php echo $_SESSION['ordenacao']; ?>",
                sortorder : "asc",
                usepager : true,
                title: 'Resultado da consulta SQL',
                useRp : true,
                rp : 100,
                showTableToggleBtn : false,
                width : 970,
                height : 343
            });

            function Example4(com, grid) {
                if (com == 'Delete') {
                    var conf = confirm('Delete ' + $('.trSelected', grid).length + ' items?')
                    if(conf){
                        $.each($('.trSelected', grid),
                            function(key, value){
                                $.get('example4.php', { Delete: value.firstChild.innerText}
                                    , function(){
                                        // when ajax returns (callback), update the grid to refresh the data
                                        $(".flexme4").flexReload();
                                });
                        });    
                    }
                }
                else if (com == 'Edit') {
                    var conf = confirm('Edit ' + $('.trSelected', grid).length + ' items?')
                    if(conf){
                        $.each($('.trSelected', grid),
                            function(key, value){
                                // collect the data
                                var OrgEmpID = value.children[0].innerText; // in case we're changing the key
                                var EmpID = prompt("Please enter the New Employee ID",value.children[0].innerText);
                                var Name = prompt("Please enter the Employee Name",value.children[1].innerText);
                                var PrimaryLanguage = prompt("Please enter the Employee's Primary Language",value.children[2].innerText);
                                var FavoriteColor = prompt("Please enter the Employee's Favorite Color",value.children[3].innerText);
                                var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal",value.children[4].innerText);

                                // call the ajax to save the data to the session
                                $.get('example4.php', 
                                    { Edit: true
                                        , OrgEmpID: OrgEmpID
                                        , EmpID: EmpID
                                        , Name: Name
                                        , PrimaryLanguage: PrimaryLanguage
                                        , FavoriteColor: FavoriteColor
                                        , FavoritePet: FavoriteAnimal  }
                                    , function(){
                                        // when ajax returns (callback), update the grid to refresh the data
                                        $(".flexme4").flexReload();
                                });
                        });    
                    }
                }
                else if (com == 'Add') {
                    // collect the data
                    var EmpID = prompt("Please enter the Employee ID","5");
                    var Name = prompt("Please enter the Employee Name","Mark");
                    var PrimaryLanguage = prompt("Please enter the Employee's Primary Language","php");
                    var FavoriteColor = prompt("Please enter the Employee's Favorite Color","Tan");
                    var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal","Dog");

                    // call the ajax to save the data to the session
                    $.get('example4.php', { Add: true, EmpID: EmpID, Name: Name, PrimaryLanguage: PrimaryLanguage, FavoriteColor: FavoriteColor, FavoritePet: FavoriteAnimal  }
                        , function(){
                            // when ajax returns (callback), update the grid to refresh the data
                            $(".flexme4").flexReload();
                    });
                }
            }
</script>

 

Já olhei no console e não há erros.

Origado desde já!

Editado por JoeJr
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

entrei no código fonte da página, e o campo do input está sem name, onde provavelmente deveria estar como : name="page", pois a query pega o valor do input e coloca no LIMIT para fazer a paginação.

Porém ao inserir o name no input pelo código fonte da página, deu mais ou menos certo. 

Quando troquei para a página 2, funcionou, porém foi setado na query um LIMIT 2,10, e então não consigo fazer a paginação novamente em seguida, pois ele entende que só há aquilo de registros por causa do limit. Gostaria de saber como posso fazer com que a página continue fazendo a paginação de acordo com o meu LIMIT.

 

 

Query:

 

$page = @$_POST['page'];
$rp = @$_POST['rp'];
$sortname = @$_POST['sortname'];
$sortorder = @$_POST['sortorder'];
 
if (!$sortname) $sortname = $_SESSION['ordenacao'];
if (!$sortorder) $sortorder = 'asc';
 
$sort = "ORDER BY $sortname $sortorder";
 
$start = (($page-1) * $rp);
 
$limit = "LIMIT $start, $rp";
 
$stringSQL = "select $exibicao from $tabela $Where $orderBy $limit";
 
Obs: O flexigrid está dentro de um iframe sem src, e não sei como faço para fazer as alterações, por isso inseri o name no input pelo código fonte.
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...