defaultValue = another column?

QuestionsdefaultValue = another column?
Tim Moore asked 5 months ago

Is there an easy way to make the defaultValue of a column equal the results of another column or query?

$g->select_command = “SELECT * FROM tbl_job
(SELECT (MAX(job_number) + 1) AS max_job
FROM tbl_job) top_job
LEFT JOIN tbl_customer ON customer_id = fk_customer
LEFT JOIN tbl_proj_man ON fk_proj_id = proj_id

$col = array();
$col[“title”] = “max_job”;
$col[“name”] = “max_job”;
$col[“width”] = “50”;
$col[“hidden”] = true;
$col[“editable”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Job Number”;
$col[“name”] = “job_number”;
$col[“link”] = “addunit.php?job={job_id}”;
$col[“width”] = “50”;
$col[“hidden”] = false;
$col[“editable”] = true;
$col[“editrules”] = array(“required”=>true, “number”=>true, “minValue”=>1000, “maxValue”=>9999);
$col[“editoptions”][“defaultValue”] = “{max_job}”
$cols[] = $col;

I simply want to find the next job_number in the DB and make it the default value in the col job_number. Thanks in advance.

2 Answers
Abu Ghufran Staff answered 5 months ago

Hello, The default value may not work in your case as it is only set for the first time and you will need latest job-id every time you open add form.

So, alternate solution would be to call an ajax request which returns job-id and set it in your job-number field.

For demo, refer this code:

See line 25,35,63

Abu Ghufran - Dev Team
PHP Grid Framework
Tim answered 5 months ago

Abu, thanks again. works perfectly!

Your Answer

15 + 1 =

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:

As you found this post useful...

Follow us on social media!

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

Let us improve this post!