Defining Static column that doesn't break add/edit

QuestionsDefining Static column that doesn't break add/edit
Mark asked 8 months ago

Hi Abu,

I’m struggling with what I think is a simple problem but I can’t seem to solve it.

I want to include a column on my grid that is not a database column but that I can edit and does not break your insert.
I have a table (mytable) with 2 fields. F1 & F2
I want my grid to display columns F1, F2 and F3 where F3 is a non-database column, editable and which I will use in an insert event to modify one of the table fields.

If I define the grid select as “select *, “ ” as F3 from mytable” the grid displays fine but when I try to insert a record it fails with “Couldn’t execute query. Unknown column ‘F3’ in ‘field list’”

I know I can work around this by handling the insert myself in the insert event but before I do I thought I’d ask you first if there was a simpler way

2 Answers
Abu Ghufran Staff answered 8 months ago

For non-db editable column, you need to use custom on_insert event code as grid library does not understand that it does not exist in table.

When using on_insert, There are 2 options.

$e[“on_insert”] = array(“add_client”, null, true); …. OR

$e[“on_insert”] = array(“add_client”, null, false);

When you set 3rd param to true, both your code and grid code will be executed and in later case only your custom code will be executed with no grid based insert query.

So, what you can do is to make 3rd param true and process your custom column f3, then unset it and leave other insert to be performed by grid.

function add_client($data)

// perform insert call on f3 and to avoid insert error unset it.


More here:

Abu Ghufran - Dev Team
PHP Grid Framework
Mark Moran answered 8 months ago

Great solution Abu,



Your Answer

10 + 3 =

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 / 5. Vote count:

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

Let us improve this post!