custom column: current row id in function arguments

Questionscustom column: current row id in function arguments
Giovanni Luca Bonelli asked 8 years ago

I have a first table used for add/edit/delete.Next I'm trying populate a custom column not db driven, with a function that return "yes" if exist a specific row in another table (table2).
In this function, I need to use current row id so I write:

$col = array();
$col["name"] = "id_task";
$cols[] = $col;

$col = array();
$col["name"] = "custom_col";
$col……….
$col……….
$col["default"] = check_if_exist("{id_task}");
$cols[] = $col;

function check_if_exist($tskid)
{
global $g;
$check_sql = "SELECT count(*) as c from table2
WHERE table2.task_id = $tskid
AND table2.ordine_id = $myvar";
$rs = $g->get_one($check_sql);
if ($rs["c"] > 0)
return "yes";
else
return "no";
}

Naturally {id_task} in function arguments doesn't work so $tskid variable is always empty.
How can I succesfully pass current row id for my check query???

Thank You.

1 Answers
Abu Ghufran answered 8 years ago

You can use on_data_display event with that column, and put your logic in side its callback.

$col["on_data_display"] = array("display_field","");

function display_field($data)
{
$id = $data["id_task"];
// your code
}

Refer docs > Dynamic Content > extended conditional data

Your Answer

4 + 1 =

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?