Master-Detail with custom events

QuestionsMaster-Detail with custom events
Cliff asked 10 years ago

Can you help my please – I am using a master-detail grid with custom events. I need to pass a column value from the detail grid to my custom delete handler but can't figure out the correct way of doing it. I already have update and add handlers working but I had to use different coding in each to retrieve the column values.
In the update function I just use $data["params"]["idSection"] to retrieve the values from the detail grid and this works fine. In the add function I had to use:
$id = intval($_GET["rowid"]);
$data["params"]["idRoute"] = $id;
and then the value from $data["params"]["idRoute"] works.

Neither of these seems to work in my delete function! I have studied all of the relevant demos but none seem to cover this particular combination of master-detail with cutom events.
Can you please explain the correct approach to returning column values from the detail grid to the event handlers.

Many thanks,


5 Answers
Abu Ghufran answered 10 years ago

Hello Cliff,

In delete event handler, only id (or first column) is passed as parameter. You need to fetch other details by querying database.
In custom-events.php sample, it is mentioned like this:

function delete_client($data)
These comments are just to show the input param format
$data => Array
[client_id] => 2

Cliff answered 10 years ago

Ah, OK, I understand. I am actually dealing with many-to-many relationships so this makes things a little more complex when doing deletes, but I can see how to work around the problem. Thanks again for such a prompt response.


Cliff answered 10 years ago

Sorry but I'm still struggling with this. The first column of my detail grid is not being returned. I seem to be getting the key value from the main grid rather than the detail grid. In my master grid I have:

$opt["detail_grid_id"] = "list2";
$opt["subgridparams"] = "idRoute";

and idRoute is correctly passed to the detail grid. In the detail grid I have:

$dg->select_command = "Select idRouteSection,idRoute,idSection,sectionName,sectionDesc from vw_sectionsbyroute where idSection in (select fk_idSection from tblroutesection where fk_idRoute = $idRoute)";

and the first column of the detail grid is declared as:

$col = array();
$col["title"] = "Route-Section ID"; // caption of column
$col["name"] = "idRouteSection"; // grid column name, same as db field or alias from sql
$col["width"] = "3"; // width on grid
$col["editable"] = true;
$col["hidden"] = false;
$cols1[] = $col;

I'm calling the delete event handler:
$e["on_delete"] = array("delete_section", null, false);

and in the delete event handler I have:
$id = intval($_GET["rowid"]);

The value being passed in $id is the row key from the main grid (idRoute) and not the row key from the detail grid (idRouteSection).

Any suggestions please?



Abu Ghufran answered 10 years ago

The first column (pk) of detail grid can be accessed by: $data["id"]
You can also print_r($data); and see the output in firebug ajax call response.

Cliff answered 10 years ago

OK, got it now! Many thanks for your excellent support.

Your Answer

1 + 5 =

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?