Cannot add a record on a grouped Grid

QuestionsCannot add a record on a grouped Grid
Greg asked 9 years ago

Hi,

I have two questions on the same topic that might contradict one another.

I have a grouped grid that is built from a M-to-M relationship – when I go to update a row, it tries to enter the grouped column (which is not from the table that I want to update). All I want is to have the Grouped Column be added as an FK to the main entry?

I'm guessing I need to do custom queries here on the save?

In addition, on my update (or even my add), the column that I have grouped by, is there a way in the ADD operation for me to default to the group and not let people select anything else?

Thanks – Greg

1 Answers
Abu Ghufran answered 9 years ago

If your main table has FK column (my_fk_col), then you can have on_update event handler and set the value of that particular column in php code.

$e["on_update"] = array("update_client", null, true);
$grid->set_events($e);
function update_client($data)
{
$data["params"]["my_fk_col"] = "my default value";
}

This way, each time you update, the default value will be set in update sql.
Similar process can be used for add. Refer event handler sample code from docs.

In case of issue, you can always email me code for review.

Your Answer

14 + 19 =

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?