diff options
| author | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-03-23 08:26:39 +0000 |
|---|---|---|
| committer | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-03-23 08:26:39 +0000 |
| commit | 69fb19b8abf21b318401e7428dc4e68d064be284 (patch) | |
| tree | 33a45582c0598b611c04ef02218b5250c19481a5 /packages/fcl-web/src | |
| parent | d52b610c1ec804c31667798f3ac29930a9c9fc0d (diff) | |
| download | fpc-69fb19b8abf21b318401e7428dc4e68d064be284.tar.gz | |
* AllowRow event
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17167 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-web/src')
| -rw-r--r-- | packages/fcl-web/src/webdata/extjsjson.pp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/packages/fcl-web/src/webdata/extjsjson.pp b/packages/fcl-web/src/webdata/extjsjson.pp index 447a223580..01595bdc74 100644 --- a/packages/fcl-web/src/webdata/extjsjson.pp +++ b/packages/fcl-web/src/webdata/extjsjson.pp @@ -28,6 +28,8 @@ type { TExtJSJSONDataFormatter } TJSONObjectEvent = Procedure(Sender : TObject; AObject : TJSONObject) of Object; TJSONExceptionObjectEvent = Procedure(Sender : TObject; E : Exception; AResponse : TJSONObject) of Object; + TJSONObjectAllowRowEvent = Procedure(Sender : TObject; Dataset : TDataset; Var Allow : Boolean) of Object; + TJSONObjectAllowEvent = Procedure(Sender : TObject; AObject : TJSONObject; Var Allow : Boolean) of Object; TExtJSJSONDataFormatter = Class(TExtJSDataFormatter) private @@ -37,13 +39,18 @@ type FAfterRowToJSON: TJSONObjectEvent; FAfterUpdate: TJSONObjectEvent; FBeforeDataToJSON: TJSONObjectEvent; + FBeforeDelete: TNotifyEvent; + FBeforeInsert: TNotifyEvent; FBeforeRowToJSON: TJSONObjectEvent; + FBeforeUpdate: TNotifyEvent; + FOnAllowRow: TJSONObjectAllowRowEvent; FOnErrorResponse: TJSONExceptionObjectEvent; FOnMetaDataToJSON: TJSONObjectEvent; FBatchResult : TJSONArray; Function AddIdToBatch : TJSONObject; procedure SendSuccess(ResponseContent: TStream; AddIDValue : Boolean = False); protected + function AllowRow(ADataset : TDataset) : Boolean; virtual; Procedure StartBatch(ResponseContent : TStream); override; Procedure NextBatchItem(ResponseContent : TStream); override; Procedure EndBatch(ResponseContent : TStream); override; @@ -77,12 +84,18 @@ type Property BeforeDataToJSON : TJSONObjectEvent Read FBeforeDataToJSON Write FBeforeDataToJSON; // Called when an exception is caught and formatted. Property OnErrorResponse : TJSONExceptionObjectEvent Read FOnErrorResponse Write FOnErrorResponse; + // Called to decide whether a record is sent to the client; + Property OnAllowRow : TJSONObjectAllowRowEvent Read FOnAllowRow Write FOnAllowRow; // After a record was succesfully updated Property AfterUpdate : TJSONObjectEvent Read FAfterUpdate Write FAfterUpdate; // After a record was succesfully inserted. Property AfterInsert : TJSONObjectEvent Read FAfterInsert Write FAfterInsert; // After a record was succesfully inserted. Property AfterDelete : TJSONObjectEvent Read FAfterDelete Write FAfterDelete; + // From TCustomHTTPDataContentProducer + Property BeforeUpdate; + Property BeforeInsert; + Property BeforeDelete; end; implementation @@ -337,9 +350,12 @@ begin ACount:=PageSize; While (not DS.EOF) and ((PageSize=0) or (ACount>0)) do begin - Inc(RCount); - Dec(ACount); - Rows.Add(RowToJSON); + If AllowRow(DS) then + begin + Inc(RCount); + Dec(ACount); + Rows.Add(RowToJSON); + end; DS.Next; end; If (PageSize>0) then @@ -411,6 +427,13 @@ begin end; end; +function TExtJSJSONDataFormatter.AllowRow(ADataset: TDataset): Boolean; +begin + Result:=True; + If Assigned(FOnAllowRow) then + FOnAllowRow(Self,Dataset,Result); +end; + procedure TExtJSJSONDataFormatter.StartBatch(ResponseContent: TStream); begin If Assigned(FBatchResult) then |
