PK value of master detail

QuestionsPK value of master detail
Samsun asked 9 years ago

Mr Abu,

I have master detail grid, then i want to get PK value of the master when i click add or edit butto in detail grid.
How i get the pk value?

Regards,
Samsun

3 Answers
Abu Ghufran answered 9 years ago

To get master grid row id on clientside:

jQuery('#list1').jqGrid('getGridParam','selrow');

To set in detail grid hidden field (test):

$opt["edit_options"]["afterShowForm"] = 'function (form) { $("#test").val( jQuery('#list1').jqGrid('getGridParam','selrow') ); }';

To get master grid row id on server side in on_insert/on_update events, use $_GET[rowid] as in demos/masterdetail/master-detail.php

function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["client_id"] = $id;
}

function update_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["client_id"] = $id;
}

Abu Ghufran answered 9 years ago

I am unable to identify the issue in it.
Can you email me steps and screenshots to generate this case?

Thanks.

Email: [email protected]

Samsun answered 9 years ago

in detail my code like this:
$cid = intval($_GET["ID"]);// ex.: 1
$sql_2 =" SELECT * from table where id=$cid";
$g->select_command = "SELECT * from table where id=$cid";

in select command $cid value is true, like this:
$g->select_command = "SELECT * from table where id=1";

but in $sql_2 value is wrong, like this
$sql_2 =" SELECT * from table where id=0";

would you like to solve my problem?

Regards,
Samsun

Your Answer

14 + 7 =

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?