Get KoolPHP UI with 30% OFF!

Format Decimal place in KoolGrid

brian
Sorry if this has already been answered but I simply could not find it.
I have a KoolGrid which gets integers from the database. I would like to use GridBoundColumn but whatever works is fine. My integers in the database will always have 2 decimal places assumed. For example 1500 is 15.00 and 475 is 4.75.
When I try GridNumberColumn, it is always adding 2 decimal places behind my integers. For example 1500 becomes 1500.00. 475 becomes 475.00.
Is there some format option that will allow me to place the decimal where I want it? Thanks much!
Posted Jan 9, 2018 Kool
David
Hi Brian,
Please use the following command to remove the decimal places:
$col = new GridNumberColumn();
$col->DecimalNumber = 0;

For more option please refer to this documentation:
https://doc.koolphp.net/Controls/KoolGrid/PHP/GridNumberColumn/index.php#DecimalNumber
Please let us know if you need any help via forum, the ticket system on our website or email. Thanks!
Posted Jan 10, 2018 Kool
brian
Hi David,
Thanks for responding.
I don't want to remove the decimal, I want to be able to use the decimal.
For example I have an integer in the database that's 1900. I need to display that integer as 19.00 in the GridNumberColumn.
When I use $col->DecimalNumber = 2, it formats my 1900 as 1900.00. It always attaches 2 decimals to the end of my integers.
Is there another way to do this?
Posted Jan 11, 2018 Kool
Anthony Amolochitis
You could use the grid event handler to customize behavior that way. I use the grid event handlers all of the time and they work great. You can do just about anything with your data using them.
I added a link for you for a basic structure on one, but you need to add the event for loading the row.
https://www.koolphp.net/forum/threads/82.1/koolgrid-with-an-event-handler-class--basic-crud-ops-included-in-the-class.html
What you are trying to format seems to be a non standard and the way of storing a float number as an integer seems a bit odd to me. I'm sure there is a reason for it though. I do not believe the grid column will add that decimal to the integer since the integer is not a float number to be formatted. I could be wrong though. Maybe the developers will look into this as well.
Hope this helps.
Posted Jan 12, 2018 Kool
Anthony Amolochitis
Did you ever get this issue resolved? Just curious.
Posted Feb 22, 2018 Kool
brian
Hi Anthony,
I didn't get an alert that you previously replied. Sorry about that. I will look over your response, give it a try this week and let you know!
Posted Feb 22, 2018 Kool