Conditional Button

QuestionsConditional Button
Javier Lopez asked 9 years ago

Hello.

I have the next code:

$col = array();
$col["title"] = 'ENVIADO?';
$col["name"] = 'ds_enviado';
$col["width"] = '63';
$col["editable"] = false;
$col["frozen"] = true;
//$col["hidden"] = true;
$cols[] = $col;

(This Column only display 2 values: "S" or "N")

I need put a button in other Column only if the value of the column is "S"

In the Buttom Column i write:
$col["condition"] = $row["ds_id"] == "S";

But not work….

Can help me?
Thanks!

2 Answers
Abu Ghufran answered 9 years ago

For button column, you can set on_data_display event and in callback check value of row to show button.
e.g.

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

function display_button($data)
{
$v = $data["ds_enviado"];
if ($v == "S")
return "<input type='button'>";
else
return "-";
}

Javier Lopez answered 9 years ago

Ok, Thanks!

But i use the next code….

$buttons_html_enviar = "<a target='_self' ….'>SOLICITAR</a>";
$buttons_html_ver = "<a target='_self' ….'>VER</a>";

$col["condition"] = array('$row["ds_enviado"] == "S"',$buttons_html_ver,$buttons_html_enviar);

$col["default"] = $buttons_html;

If the HTML of the $buttons_html_ver display a blank value works…

I think my method is not too profesional… but solved the problems

Thanks again a sorry for my english

Your Answer

8 + 7 =

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?