Problem with Pagination and old code

Talk about Sorting & Paging problems, issues etc.

Moderator: alexandrleonenko

Abagadaia
Newbie
Newbie
Posts: 5
Joined: Jan 13th, '14, 18:50

Problem with Pagination and old code

Postby Abagadaia » Mar 5th, '14, 12:09

Hello people,

I have the following old code in my:

Code: Select all

   $DB_TYPE = 'mysql';
   $DB_USER = $db_user;         
   $DB_PASS = $db_pass;           
   $DB_HOST = $db_server;       
   $DB_NAME = $db_database;   
   
   ob_start();
   
   $db_conn_dg = DB::factory($DB_TYPE);
   $db_conn_dg->connect(DB::parseDSN($DB_TYPE.'://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
   
   $sql=" SELECT distinct "
             . "matricula.turmas as turma, count(matricula.codigo) as Qtd, "
             . "REPLACE( REPLACE( REPLACE( FORMAT(avg(year(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(aluno.datab)))), 2), '.', '|'), ',', '.'), '|', ',') as Idade, "
             . "REPLACE( REPLACE( REPLACE( FORMAT( avg(matricula.frequencia), 2), '.', '|'), ',', '.'), '|', ',') as frequencia, "
             . "REPLACE( REPLACE( REPLACE( FORMAT( avg(matricula.medianota), 2), '.', '|'), ',', '.'), '|', ',') as Media "
             . "FROM aluno INNER JOIN matricula ON aluno.nasid = matricula.alunoid WHERE (matricula.situacao='ATIVO' or matricula.situacao='EVADIDO') and aluno.EscolaID = '$id' and matricula.EscolaID = '$id' "
          . "group by matricula.turmas ";
   
   $dgrid = new DataGrid(false, false, "aln_", DATAGRID_DIR);
   
   $dgrid->SetPostBackMethod("ajax");
   $dgrid->SetInterfaceLang("pb");
   $dgrid->SetEncoding("utf8");
   $modes = array(
         "add"    =>array("view"=>false, "edit"=>false, "type"=>"link"),
         "edit"    =>array("view"=>false, "edit"=>false,  "type"=>"link", "byFieldValue"=>""),
         "cancel"  =>array("view"=>false, "edit"=>false,  "type"=>"link"),
         "details" =>array("view"=>false, "edit"=>false, "type"=>"image"),
         "delete"  =>array("view"=>false, "edit"=>false,  "type"=>"image")
   );
   $dgrid->setModes($modes);
   
   $dgrid->dataSource($db_conn_dg, $sql, "Anos", "ASC");   
   
   $dgrid->AllowPrinting(true);
   $dgrid->setAutoColumnsInViewMode(true);
   $dgrid->setTableEdit("aluno", "Codigo", "");
   
   $exporting_option = true;
   $export_all = false;
   $dgrid->AllowExporting($exporting_option, $export_all);
   $exporting_types = array(
         'csv'=>'false', 'xls'=>'true', 'pdf'=>'true', 'xml'=>'false', 'doc'=>'false'
   );
   $dgrid->AllowExportingTypes($exporting_types);
   
    $dgrid->allowSorting(true);
   $dgrid->allowPaging(true, false, 'N #', false);
   
    $dgrid->bind();       
    ob_end_flush(); 


But pagination don't work, whats the problem?

Abagadaia
Newbie
Newbie
Posts: 5
Joined: Jan 13th, '14, 18:50

Re: Problem with Pagination and old code

Postby Abagadaia » Mar 5th, '14, 17:31

Hey people,

I tried to update the code using the last methods in the apphp help, follow the code:

Code: Select all

   <?php
   $DB_TYPE = 'mysql';
   $DB_USER = $db_user;         
   $DB_PASS = $db_pass;           
   $DB_HOST = $db_server;       
   $DB_NAME = $db_database;   
   
   ob_start();
   
    $sql=" SELECT distinct "
             . "matricula.turmas as turma, count(matricula.codigo) as Qtd, "
             . "REPLACE( REPLACE( REPLACE( FORMAT(avg(year(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(aluno.datab)))), 2), '.', '|'), ',', '.'), '|', ',') as Idade, "
             . "REPLACE( REPLACE( REPLACE( FORMAT( avg(matricula.frequencia), 2), '.', '|'), ',', '.'), '|', ',') as frequencia, "
             . "REPLACE( REPLACE( REPLACE( FORMAT( avg(matricula.medianota), 2), '.', '|'), ',', '.'), '|', ',') as Media "
             . "FROM aluno INNER JOIN matricula ON aluno.nasid = matricula.alunoid WHERE (matricula.situacao='ATIVO' or matricula.situacao='EVADIDO') and aluno.EscolaID = '$id' and matricula.EscolaID = '$id' "
          . "GROUP BY matricula.turmas ";
   
   $dgrid = new DataGrid(true, true, "aln_");
   
   $dgrid->DataSource('PEAR', $DB_TYPE, $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, array());
   
   $dgrid->SetPostBackMethod("ajax");
   $dgrid->SetInterfaceLang("pb");
   $dgrid->SetEncoding("utf8");
   
   $modes = array(
         "add"    =>array("view"=>false, "edit"=>false, "type"=>"link"),
         "edit"    =>array("view"=>false, "edit"=>false,  "type"=>"link", "byFieldValue"=>""),
         "cancel"  =>array("view"=>false, "edit"=>false,  "type"=>"link"),
         "details" =>array("view"=>false, "edit"=>false, "type"=>"image"),
         "delete"  =>array("view"=>false, "edit"=>false,  "type"=>"image")
   );
   $dgrid->setModes($modes);
   
   $dgrid->AllowPrinting(true);
   $dgrid->setAutoColumnsInViewMode(true);
   
   $dgrid->AllowExporting(true, false);
   $exporting_types = array(
         'csv'=>'false', 'xls'=>'true', 'pdf'=>'true', 'xml'=>'false', 'doc'=>'false'
   );
   $dgrid->AllowExportingTypes($exporting_types);
   
    $dgrid->allowSorting(true);
   $dgrid->allowPaging(true, false, 'N #', false);
   
    $dgrid->Bind(true);       
    ob_end_flush(); 
   ?>


And the paging still don't working. :/

administrator
Site Admin
Site Admin
Posts: 6004
Joined: Jan 7th, '09, 23:18
Contact:

Re: Problem with Pagination and old code

Postby administrator » Mar 6th, '14, 08:21

What version do you work with?
Please show us your page with datagrid online.

Abagadaia
Newbie
Newbie
Posts: 5
Joined: Jan 13th, '14, 18:50

Re: Problem with Pagination and old code

Postby Abagadaia » Mar 6th, '14, 12:36

Hello Admin,

I'm using version 7.9.9. PHP 5.3.27 and Apache 2.2. The database is MYSQL 5.0.77.

The methods Ajax and Post is not working of the datagrid.

Testing on Google Chrome and Mozilla Firefox. If you want I can send the log of Firebug and/or Chrome Dev Tools.

I can't liberate the page because its an internal system, we don't have an external server to access for now.

Regards,

administrator
Site Admin
Site Admin
Posts: 6004
Joined: Jan 7th, '09, 23:18
Contact:

Re: Problem with Pagination and old code

Postby administrator » Mar 9th, '14, 07:28

Check your browser's javascript errors panel. Do you see any javascript error?


Return to “Settings: Sorting & Paging”