Add/Edit 2 table in 1 grid

Talk about implementing of customized templates

Moderators: ne_moj, zewa

seageath
Junior
Junior
Posts: 11
Joined: Dec 8th, '14, 22:32

Add/Edit 2 table in 1 grid

Postby seageath » Feb 1st, '15, 16:56

Hi all,

I need advice on the following scenario of my grid below. I have 1 grid (called it GridA) and I have 2 tables (tableA & tableB).
Up to this moment I managed to use GridA to add both table in 1 form (ADD form) so during save the grid will save to tableA and tableB.
But I encountered a challenge when I am about to do EDIT, so far only table B which are displayed on the EDIT Mode so I can't make any update on tableA.
Is there any setting that I missed? Please help to advise, attached is the code.

Code: Select all


   $table_name  = "playersgames";
   $primary_key = "PlayersGamesID";
   $condition   = "";
   $dgrid->SetTableEdit($table_name, $primary_key, $condition);

   ##  *** set columns in edit mode 
   $em_columns = array(

// This is tableA

   'PlayerID'          =>array('header'=>'PlayerID', 'type'=>'hidden',     'req_type'=>'st', 'default'=>$strPlayerID, 'value'=>$strPlayerID, 'unique'=>'false', 'visible'=>'true'),
   "SitesID"            =>array("header"=>"Sites ID", "type"=>"enum", "req_type"=>"ry", "width"=>"100px", "title"=>"", "readonly"=>"false", "maxlength"=>"255", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "source"=>$arrSites, "view_type"=>"dropdownlist", "on_js_event"=>""),
"maxlength"=>"1024", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple", "resizable"=>"true", "upload_images"=>"false", "rows"=>"3", "cols"=>"50"),

// This is tableB

   "PlayerBankAcctID"  =>array("header"=>"Member Account ID", "type"=>"enum", "req_type"=>"ry", "width"=>"110px", "title"=>"", "readonly"=>"false", "maxlength"=>"255", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$arrBanks, "view_type"=>"dropdownlist"),         
   "PlayerDeposit"    =>array("header"=>"Deposit", "type"=>"textbox", "req_type"=>"ry", "width"=>"100px", "title"=>"", "readonly"=>"true", "maxlength"=>"1024", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple", "resizable"=>"true", "upload_images"=>"false", "rows"=>"3", "cols"=>"50"),
   "PlayerWithdrawal"    =>array("header"=>"Withdrawal", "type"=>"textbox", "req_type"=>"ry", "width"=>"100px", "title"=>"", "readonly"=>"true", "maxlength"=>"1024", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple", "resizable"=>"true", "upload_images"=>"false", "rows"=>"3", "cols"=>"50"),
   "PlayerBankBalance" =>array("header"=>"Bank Balance", "type"=>"textbox", "req_type"=>"ry", "width"=>"100px", "title"=>"", "readonly"=>"true", "maxlength"=>"1024", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple", "resizable"=>"true", "upload_images"=>"false", "rows"=>"3", "cols"=>"50"),
   "CoinBalance"       =>array("header"=>"Coin Balance", "type"=>"textbox", "req_type"=>"ry", "width"=>"100px", "title"=>"", "readonly"=>"true", "maxlength"=>"1024", "default"=>"0", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple", "resizable"=>"true", "upload_images"=>"false", "rows"=>"3", "cols"=>"50"),
   'Notes'           =>array("header"=>"Notes", "type"=>"textbox", "req_type"=>"st", "width"=>"110px", "title"=>"", "readonly"=>"false", "maxlength"=>"255", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
   'OprID'          =>array('header'=>'OprID', 'type'=>'hidden',     'req_type'=>'st', 'default'=>$strOprID, 'value'=>$strOprID, 'unique'=>'false', 'visible'=>'true'),
   'CompanyID'       =>array('header'=>'CompanyID', 'type'=>'hidden',     'req_type'=>'st', 'default'=>$strCompanyID, 'value'=>$strCompanyID, 'unique'=>'false', 'visible'=>'true'),   
   );




thanks in advance

-sea-

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

Re: Add/Edit 2 table in 1 grid

Postby administrator » Feb 1st, '15, 19:09

If you use 2 DataGrids on one page you must firstly update values in the 2nd table and only then in the 1st one.

seageath
Junior
Junior
Posts: 11
Joined: Dec 8th, '14, 22:32

Re: Add/Edit 2 table in 1 grid

Postby seageath » Feb 3rd, '15, 12:30

administrator wrote:If you use 2 DataGrids on one page you must firstly update values in the 2nd table and only then in the 1st one.


So it's not possible for Edit MODE to update 2 table by only using 1 grid.
I noticed that there is a setting for table and key like below

Code: Select all

## +---------------------------------------------------------------------------+
   ## | 7. Add/Edit/Details Mode Settings:                                        |
   ## +---------------------------------------------------------------------------+
   $table_name  = "playersgames";
   $primary_key = "PlayersGamesID";
   $condition   = "";
   $dgrid->SetTableEdit($table_name, $primary_key, $condition);


Is it why when edit mode my field that I have already defined did not appear on the grid?
It's only appear on ADD MODE.

-sea-

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

Re: Add/Edit 2 table in 1 grid

Postby administrator » Feb 3rd, '15, 18:58

No, you may do it only if you use so-called "after" operations:
http://www.apphp.net/forum/viewtopic.php?f=33&t=97

seageath
Junior
Junior
Posts: 11
Joined: Dec 8th, '14, 22:32

Re: Add/Edit 2 table in 1 grid

Postby seageath » Feb 17th, '15, 14:46

Thank you Admin. I will take a look the code again.

=sea=


Return to “Add/Edit/View Mode Templates Implementing”