Special 'fixed' db field


In my db table i have a field that (in a certain context) allways has a fixed value.
The value is know to the script (php) when it starts creating the grid.
(I use render_table, since i’m not able to get things working with render_sql)

Is there a way to convey that value, so that I can use it in the onInsert event to set
the field to the correct value ? (Or is there any other way to set default values for fields that act in the indert new record situation ?)
And the same for the filter event, that I will use to filter rows out where this field has an other value;


//adding new value for DB operations
function my_code($data){
$data->add_field(“field_name”, “field_value”);
$grid->event->attach(“beforeProcessing”, “my_code”);

//setting some default filtering rule
function my_code($rules){
$rules->add(“field_name”, “field_value”,"=");
$grid->event->attach(“beforeFilter”, “my_code”);[/code]

Thanks a lot Stanislav,
but that does not solve my problem.

In your examples it’s the “field_value” that poses my problem.
It’s a variable that I have when the grid is created.

I cannot declare it global in these functions, since global is not available when they are executed.

Still, I need it, in case of insert.
(for update operations, I just transport it as an extra field, there is no problem for deletes allso)

If the users inserts a new record (row) , i need to set this field from a variable, only available as I create the grid. So what I would need is the ability to attach some (fixed) user vars to a grid, and get them back when i insert. (And, of course, since I still can not use render_sql, also in the filter function as I build up the grid -> beforeRender).

I hope my problem is more understandable now.


The moment when grid created is probably the same moment when dataprocessor is created , right?

So you can include in in the dp’s path

var dp = new DataProcessor(“some.php?field=”+field_name);

and in php code for all calls you will have


also, you can use the global userdata


this value will be sent with all DB operation calls ( grid 2.6 )

By the way - be sure at least check the field_name value, which comes from client side, it is very easy to create SQL injection atack, because field names are not escaped.

Hi Stanislav,

Thanks a lot for your help.
Works like a charm now.

b.t.w. I dont use the field name directly, so no danger.

Again, thanks a lot for your splendid help!