Menu and Datagrid

Discuss everything related to ApPHP TreeMenu. Any questions related to the ApPHP TreeMenu developing or using should be posted to this forum.

Moderators: alexandrleonenko, Milton

llinuxdude
Newbie
Newbie
Posts: 5
Joined: Dec 18th, '10, 23:50

Menu and Datagrid

Postby llinuxdude » Jan 10th, '11, 01:48

I bought the menu and the datagrid.

I used the example menu code and used the get option. On one of the menu actions I called a funcion that calls datagrid and puts it into the table. It has 18 rows of data.

The first 10 rows show. When I press the next row set action ">>>" I get a blank table.

Nothing different when I put in the debug, nothing is put on on the screen. Here is my code.

I am kinda new to php, eventhough I have been programming 'unix-c' for 15 years. I built this alot from the example code.

Any help would be great, also is there more detailed documention on these packages? Man pages ?

Thanks in advance.


Menu code

Code: Select all

$storage1=$storage->AddNode("Volumes","content/testme.php?passed_query=1");


testme.php

Code: Select all

create_db_grid( $query, $session_id );


datagrid

Code: Select all

function create_db_grid( $query_num, $session_id )
          {
          #########################################################################################################
          # Database Setup and open
          #########################################################################################################
          define ("DATAGRID_DIR", "datagrid/");                     /* Ex.: "datagrid/" */
          define ("TSM_CODE", "tsm_code/" );
          define ("PEAR_DIR", "datagrid/pear/");                    /* Ex.: "datagrid/pear/" */

          require_once( DATAGRID_DIR.'datagrid.class.php' );
          require_once( PEAR_DIR.'PEAR.php' );
          require_once( PEAR_DIR.'DB.php' );
          require_once( TSM_CODE.'tsmdb.php' );

          ob_start();

          $db_type = "pgsql";
          $user = "markc";
          $password = "markc";
          $hostname = "localhost";
          $database = "tsm_dd";
          $dsn = sprintf( "%s://%s:%s@%s/%s", $db_type, $user, $password, $hostname, $database );
          $db_conn = DB::connect( $dsn );

          if( DB::isError( $db_conn ))
              {
              Die( "Can't Connect: ".$db_conn->getMessage());
              }

          #########################################################################################################
          # build table name
          #########################################################################################################
          $table_name = "result_".$query_num;

          #########################################################################################################
          # debug stuff
          #########################################################################################################
          $debug_mode = true;
          #$debug_mode = false;

          #########################################################################################################
          # Misc stuff
          #########################################################################################################
          $messaging = true;
          $unique_prefix = "f_";
          $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
 #########################################################################################################
          # The select Statement
          #########################################################################################################
          $sql_cmd = "select * from result_info where table_name = "." '".$table_name."' and screen_display = 't'";

          $result = $db_conn->query( $sql_cmd );

          $sql_cmd = "Select ";
          $number_rows = $result->numRows( $result );

          while(  $result->fetchInto( $row ))
              {
              if( $row[3] == 1 )
                  {
                  $default_order_field = $row[4];
                  }

              $sql_cmd = $sql_cmd.$row[4]." \"".$row[1]."\"";
              if( --$number_rows != 0 )
                  {
                  $sql_cmd = $sql_cmd.", ";
                  }
              }

          $sql_cmd = $sql_cmd." from ".$table_name;

          #########################################################################################################
          # The database link to datagrid
          #########################################################################################################
          ##  *** set data source with needed options
          #$default_order_field = "vol_name";
          $default_order_type = "ASC";

          $dgrid->DataSource($db_conn, $sql_cmd, $default_order_field, $default_order_type);
          $sql_cmd = "select grid_title from commands where cmd_table = "."'".$table_name."'";
          $result = $db_conn->query( $sql_cmd );
          $result->fetchInto( $row );
          $dg_caption = $row[0];
          $dgrid->SetCaption($dg_caption);

          #########################################################################################################
          # Setup the options
          #########################################################################################################
          $modes = array(
           //  "add"      =>array("view"=>false, "edit"=>false, "type"=>"link"),
            //// "edit"     =>array("view"=>false, "edit"=>true,  "type"=>"link", "byFieldValue"=>""),
////             "cancel"  =>array("view"=>false, "edit"=>false,  "type"=>"link"),
  ////           "details" =>array("view"=>false, "edit"=>false, "type"=>"link"),
    ////         "delete"  =>array("view"=>false, "edit"=>false,  "type"=>"image")
              );

          $dgrid->SetModes($modes);
          ##  *** allow mulirow operations
          $multirow_option = false;
          $dgrid->AllowMultirowOperations($multirow_option);

          ##  *** set columns in view mode
          $modes = array( "add" => false, "insert" => false, "preview" => false, "edit" => false );
          $layouts = array( "view"=>0, "edit"=>0 );
          $dgrid->SetLayouts( $layouts );
          $dgrid->SetAutoColumnsInViewMode(true);

        ## +---------------------------------------------------------------------------+
        ## | 7. Add/Edit/Details Mode settings:                                        |
        ## +---------------------------------------------------------------------------+
        ##  ***  set settings for edit/details mode
    //       $table_name = "demo_countries";
    //      $primary_key = "id";
    //       $condition = "";
    //       $dgrid->SetTableEdit($table_name, $primary_key, $condition);

          #########################################################################################################
          # Setup the options
          #########################################################################################################
          $dgrid->Bind();
          ob_end_flush();
          }
?>

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

Re: Menu and Datagrid

Postby administrator » Jan 10th, '11, 17:17

1. Try to debug datagrid with $dgrid->debud = true; to understand what query returns when you list pages.
2. Define appropriate values for Edit Mode:
$table_name = "demo_countries";
$primary_key = "id";
$condition = "";
$dgrid->SetTableEdit($table_name, $primary_key, $condition);

Does it help now?

llinuxdude
Newbie
Newbie
Posts: 5
Joined: Dec 18th, '10, 23:50

Re: Menu and Datagrid

Postby llinuxdude » Jan 10th, '11, 17:53

Yep, same thing.

If I call this straight without the menu's loaded it works.

I figure it might be the html table that is created in the demo example....

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

Re: Menu and Datagrid

Postby administrator » Jan 11th, '11, 09:17

Please create a public page, turn On debug mode in DataGrid place it anywhere in Internet and send us a link to see this issue online

kasumovic
Expert
Expert
Posts: 87
Joined: Sep 7th, '10, 22:38

Re: Menu and Datagrid

Postby kasumovic » Oct 22nd, '13, 14:14

Hello,

I have problem with TreeMenu and DataGrid, i have one file (customer.php) with datagrid inside, but i dont get it working, i try it like this :

Code: Select all

$sdata2 = $treeMenu->AddNode('Customers','customer.php');

But this way is not possible, due 2 things (at least) :
1. TreeMenu changes home path into .../phptree/lib , so DataGrid.class.php can not be found cause DataGrid folder is .../phpgrid/, and it search them into .../phptree/lib/phpgrid (calling directly customer.php works 100%)
2. I must add "ALL" Javascripts (from DataGrid) in my main script where is TreeMenu places, and still then it is not working 100% (Get grid shown but nothing else, no action possible, unique_id__doPosback not found error message)

So what is the right way to do this ?

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

Re: Menu and Datagrid

Postby administrator » Oct 23rd, '13, 06:47

DataGrid loads own javascript files. If you call the page with datagrid with ASJAX it is not happens.
The solution is to include all needed datagrid JavaScript file as "hard-codded" in your main php file.

boby786
Newbie
Newbie
Posts: 1
Joined: Feb 4th, '14, 09:31

Re: Menu and Datagrid

Postby boby786 » Feb 4th, '14, 09:38

1. Try to debug datagrid with $dgrid->debud = true; to understand what query returns when you list pages.
2. Define appropriate values for Edit Mode:
$table_name = "demo_countries";
Play and Download crossword game online visit crossword puzzles for more details.

dewabrata
Newbie
Newbie
Posts: 1
Joined: Jun 8th, '15, 08:03

Re: Menu and Datagrid

Postby dewabrata » Jun 8th, '15, 08:33

Im need to show datagrid with node, is there any tutorial for this? Which javascript code i must put into main class? Please , i buy tree menu assumsing there is compability with the datagrid , but i think is useless now :(


Return to “ApPHP TreeMenu”