Calculated field

QuestionsCalculated field
Alec asked 11 years ago

Is is possible to create a calculated column? For example, in the database I have the phone number split into the area code (e.g. "212") and the number (e.g. "555-1212"), but in the grid I would like to display it as "212-555-1212". Is that possible, or will the grid accept a calculated column from my SQL query (SELECT CONCAT(area_code,"-",phone_number) as PHONE)?

Thank you, Alec

3 Answers
Abu Ghufran answered 11 years ago

Hi,

Yes it will work. For update/insert case, you need to have custom on_update / on_insert event callbacks (in package demos)

Raja Selvam answered 11 years ago

I am trying to do the same above but dont know what to do.

I have street, area, City, State and Zip Code in my table. When the same is displayed in the grid in one column I want it as Street, Area, City, State, Zip.

Appreciate your help.

Abu Ghufran answered 11 years ago

You can use CONCAT function of SQL to make them as a single field, and use that field alias as grid column.

e.g.

select f1,f2, concat(Street, Area, City, State, Zip) as address …

and

$col["name"] = "address";

Your Answer

10 + 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?