Master Detail get column variable to save to detail table

QuestionsMaster Detail get column variable to save to detail table
uzoma amaeshi asked 9 years ago

Hi,

i've been having this issue and i need help. i have to tables (master-detail obviously), the id (which is the primary key i can save to the detail possible is fine). but i need to pass the value of another column and when i save it. it returns zero. below is my code.

$opt["subgridparams"] = "LevelHeadNum";

….
$e["on_insert"] = array("add_tbl", null, true);
$grid->set_events($e);
….

function add_tbl(&$data)
{
$id = intval($_GET["rowid"]);
$pl = intval($_GET["LeadHeadNum"]);
$data["params"]["HierarchyAdminNum"] = $id;
$data["params"]["ParentNum"] = $pl;
}

The column "ParentNum" keeps saving as 0; it never receives the variable and saves it. It should receive data from the "LeadHeadNum" column in the master grid.

5 Answers
Abu Ghufran answered 9 years ago

You can debug using firebug, if on ADD ajax request, this GET var (leadHeadnum) is passed or not.
You can also try comparing with demos/master-detail/master-detail.php demo as the vars e.g. company can be used inside detail grid add callback using $_GET.

uzoma amaeshi answered 9 years ago

Thanks Abu for your swift response but the get var(LeadHeadNum) is passed in the string from the master detail. but my problem is that i cant access it from the add_tbl function. as stated above, the $pl variable is always 0;

Abu Ghufran answered 9 years ago

If LeadHeadNum is string and non-numeric, then you must remove intval(), otherwise it will always be zero.

$pl = intval($_GET["LeadHeadNum"]);

change to:

$pl = $_GET["LeadHeadNum"];
if (empty($pl)) $pl = "";

uzoma amaeshi answered 9 years ago

Thanks again but that's not my problem as i already have all that in check. Please i would like to send you the complete file for your perusal.

Abu Ghufran answered 9 years ago

Email me code at [email protected]
Along with sample sql dump.

Your Answer

17 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?