summaryrefslogtreecommitdiff
path: root/packages/fcl-web/src/webdata/extjsjson.pp
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-10 19:20:48 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-10 19:20:48 +0000
commit160cc1e115eeb75638dce6effdd16b2bc810ddb4 (patch)
treeb791a95695a7cf674e61a6153139c6f9c6c491fa /packages/fcl-web/src/webdata/extjsjson.pp
parent3843727e74b31bbf2a34e7e3b89ee422269f770e (diff)
parent413a6aa6469e6c297780217a27ca91363c637944 (diff)
downloadfpc-avr.tar.gz
* rebase to trunk@17295avr
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/avr@17296 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-web/src/webdata/extjsjson.pp')
-rw-r--r--packages/fcl-web/src/webdata/extjsjson.pp29
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