Hello,
I have a KoolGrid which is showing a list of alarms of the system.
I would like to link each row to an instance of my Alarm class.
How can I do that ? Does KoolGrid Row have a holder to carry the class on ?
Best regards.
Jayme | |
Hello,
I have a KoolGrid which is showing a list of alarms of the system. I would like to link each row to an instance of my Alarm class. How can I do that ? Does KoolGrid Row have a holder to carry the class on ? Best regards.
Posted Feb 7, 2017 , edited Feb 7, 2017
Kool
|
|
Jayme | |
As a matter of fact I would like to attach an object with properties and methods to the KoolGrid Row.
Posted Feb 7, 2017
Kool
|
|
Anthony Amolochitis | |
Use the grid event handler. On row prerender, create the object there.
I have a sample to create the handler on the following link. https://www.koolphp.net/forum/threads/82.1/koolgrid-with-an-event-handler-class--basic-crud-ops-included-in-the-class.html You can add the row prerender event to this class. Then create your object on the row dataitem array in the pre render of each row.
Posted Feb 7, 2017
Kool
|
|
Jayme | |
Hello Anthony.
Thank very much for answering me and sharing your code sample. I am very sorry, but I did not find the property you have mentioned $row->DataItem[""] on the KoolGrid documentation. I am using the KoolGrid as is. I did not make any change on its code. Best regards.
Posted Feb 7, 2017
Kool
|
|
Anthony Amolochitis | |
The DataItem array is your row array.
I discovered it in my debugger. It's there.
Posted Feb 7, 2017
Kool
|
|
Jayme | |
So, DataItem is the columns array of the row,.
Have you created an extra column to use as the holder of the class ? Best regards.
Posted Feb 7, 2017
Kool
|
|
Anthony Amolochitis | |
Yes, many times over. Notice the field names with the word "custom" in them. Those don't exist in the database.
They are created in row pre render. Example with Custom Column in conjunction with row pre render event and adding custom fields to my row.
Example of row pre render event :
Here is an image of what is made.
Posted Feb 7, 2017 , edited Feb 7, 2017
Kool
|
|
Jayme | |
Thank you again for sharing your code.
I think I should change the approach because I need to get access to the properties of the Alarm Class at client side, I think I should create the objects using JavaScript and put them in an array .
Posted Feb 7, 2017
Kool
|
|
Anthony Amolochitis | |
On pre render you can assign a custom call to the methods in your client side script as well.
I do this to click to send email notifications and other random things.
Posted Feb 7, 2017
Kool
|
|