KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Missing resource events? #3387

Open Marloes opened this topic on on Nov 20 - 7 comments

Marloes commented on Nov 20

Hi there,

I've notices that these methods are not present to be used? https://www.koolreport.com/docs/dashboard/admin/resources/#resource-events

Because I would like to use them in the adminTable and do a check before I update/delete something.

With kind regards, Marloes

Sebastian Morales commented on Nov 21

What did you meant the events were missing, did the event listeners not execute?

Marloes commented on Nov 21

Hi Sebastian,

Yes, it doen't execute ... And if I perform a IDE search on "onRecordUpdating" through all the koolreport sourcecode/scripts then I don't find this method somewhere. So it doesn't seem to exist.

With kind regards, Marloes

Sebastian Morales commented on Nov 22

You can test the resource event listener working like this:

class Customer extends Resource
{
    ...

    protected function onRecordUpdating($params)
    {
        echo "onRecordUpdating";
        exit;
        ...
        return true;
    } 

An error dialog with "onRecordUpdating" text will appear. Then replace the echo and exit commands with your database logic code.

Marloes commented on Nov 22

Hi Sebastian,

I have no idea what I did wrong earlier, I must have done something different ...sorry, but it is working now. Thx!

With kind regards, Marloes

Marloes commented on Nov 22

Ahha, I see it already. When I am using

public function updateRecord($ids, $data){

Then the method below wont work.

protected function onRecordUpdating($params)

So probably I can only use one of them?

Sebastian Morales commented on Nov 25

It's probably because the "RecordUpdating" event is fired inside updateRecord() method. If you still want to use your own updateRecord() method, you can fire the event in there like this:

    $this->fireEvent("RecordUpdating", $params); 
Marloes commented on Nov 27

Okay thx. Another question :-) While using the following

public function updateRecord($ids, $data){

I've noticed that the $data object only contains the changed fields/properties (names and values) when using the detailspage edittor (not the inline edit), but is there also a possibility to send other (unchanged) properties as well, like a so called 'dirtyField'? Because I need some values to compare in my logic.

Update: nevermind, found it: https://www.koolreport.com/docs/dashboard/admin/fields/#properties ( shouldUpdate(true) )

With kind regards, Marloes

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

Dashboard