Change value on condition

QuestionsChange value on condition
Gary Brett asked 8 years ago

Hi Abu, wonder if the grid is able to allow this? I have a field called 'leaddays' that holds a date in uk format. Is it possible to set another checkbox field 'lead_status' if the date in first columns has passed?

For example if date has past in 'leaddays' 17-04-2016, then the checkbox in 'lead_status' is ticked?

$col = array();
$col["title"] = "Status";
$col["name"] = "lead_status";
$col["width"] = "20";
$col["edittype"] = "checkbox";
$col["editoptions"] = array("value"=>"1:0"); // with these values "checked_value:unchecked_value"
$col["formatter"] = "checkbox";
$cols[] = $col;

$col = array();
$col["title"] = "Off Until"; // caption of column
$col["name"] = "leaddays"; // grid column name
$col["formatter"] = "date";
$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d-m-Y');
$col["formoptions"] = array("elmsuffix"=>'<font color=red> *</font>');
$cols[] = $col;

Many thanks

1 Answers
Abu Ghufran answered 8 years ago

With lead_status column, you can set custom data display event, e.g.

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

function set_custom_data($data)
{
$date = $data["leaddays"];
if( strtotime($date) > strtotime('now') )
$data["lead_status"] = 1;
else
$data["lead_status"] = 0;
}

Your Answer

0 + 11 =

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?