rhazell43
Below is a simple example that will display a notification if the entered date is greater that the current date.
procedure TIWCGFrame_Meds.IWCGJQDatePicker1JQDatePickerOptionsSelect(Sender: TObject; AParams: TStringList);
var
tempSelectedDate: String;
begin
tempSelectedDate := AParams.Values['dateText'];
if StrToDate(tempSelectedDate) > Date then
begin
with IWCGJQNotify1.JQNotificationNotyOptions do
begin
CloseNotification;
Buttons.Clear;
Modal := True;
Text := 'The selected date has not yet occurred';
Layout:= jqnnlCenter;
Type_:= jqnntError;
ShowNotification;
end;
// UserSession.AdsQueryPtMeds.FieldByName('DateInactive').AsDateTime := Date;
UserSession.AdsQueryPtMeds.Cancel;
end;
end;
To implement the above there are three requirements:
1) Implement the following in the IWCGJQDateTimePicker1
with IWCGJQDatePicker1 do
begin
JQDatePickerOptions.GoToCurrent := True;
DataLink.DataSource := UserSession.wwDSQueryPtMeds;
DataLink.FieldName := 'DateInactive';
end;
with IWCGJQDatePicker1.JQDatePickerOptions.OnSelect.BrowserParams.Add do
begin
ServerName := 'dateText';
BrowserScript := 'dateText';
end;
2) create the grid columns in code, the relevant code for this is
iCol:= IWCGJQGrid2.JQGridColumns.Add; // Column 3
iCol.Align:= gaCenter;
iCol.Caption := 'Inactivated';
iCol.Editable := True;
iCol.EditOptions.DatePickerOptions.Disabled := False;
iCol.Formatter := gcfControl;
iCol.FormatOptionsControl.ControlTemplate := IWCGJQDatePicker1;
iCol.Idx := 'DateInactive';
iCol.Name := 'DateInactive';
iCol.Key := False;
iCol.Sortable := True;
iCol.Width := 75;
3) Create the following type in the implementation
type
TIWCGJQGridColUpdateControlEvent = procedure(Sender: TObject; ACol: TIWCGJQGridCol; const ARowId,ACellValue: string) of object;
The explanation for the type declaration comes from the following user group post:
viewtopic.php?f=34&t=345&p=1675&hilit=datepicker#p1675Note: In the OnSelect event I reset the incorrect date on the server side. I have not yet looked at possibly error trapping the date on the browser side using the JQValidateOptions
I hope this was helpful
John