Jump to content

Recommended Posts

Posted

OK I will look at it. We will not implement this as a new component. I will try to show you how to integrate it into your application.

 

Very thanks Mr. Farshad.

 

Best Regards

  • 3 weeks later...
Posted

OK I will look at it. We will not implement this as a new component. I will try to show you how to integrate it into your application.

 

Hi Mr. Farshad

 

Can you make a sample for this pluging?

 

Or how can i use this plugin in my project ?

 

 

Best Regards

  • Administrators
Posted

To MainForm.Scrpits add:

 

Ext.override(Ext.DatePicker, {
 initComponent: Ext.DatePicker.prototype.initComponent.createInterceptor(function() {
this.plugins = [Ext.ux.JalaliDatePlugin];
 	return(true);
}) 
});

 

To ServerModule.CustomFiles add

 

files\Jalali\Jalali.js
files\Jalali\JalaliDate.js
files\Jalali\JalaliDatePlugin.js
files\Jalali\JalaliDatePlugin-fa_IR.js

 

This will change all DatePicker instances in your app to jalali calendar.

Posted

To MainForm.Scrpits add:

 

Ext.override(Ext.DatePicker, {
 initComponent: Ext.DatePicker.prototype.initComponent.createInterceptor(function() {
this.plugins = [Ext.ux.JalaliDatePlugin];
 	return(true);
}) 
});

 

To ServerModule.CustomFiles add

 

files\Jalali\Jalali.js
files\Jalali\JalaliDate.js
files\Jalali\JalaliDatePlugin.js
files\Jalali\JalaliDatePlugin-fa_IR.js

 

This will change all DatePicker instances in your app to jalali calendar.

 

 

Hi, Mr. Farshad

 

Thank you for your reply.

This work very good and DateTimePicker show Jalali Calendar Panel.

But have a litle problem, in the DatetTimePicker text box not show jalali Date !!! This shown a gregorian date. Event a select a jalali date and close the Jalali Panel in the text box not show Jalali Date !!!

 

Please help me.

 

Thank you and Best Regards

  • Administrators
Posted

Not sure what can be done about it. Gregorian date is used internally by both Ext JS and Delphi and this can not be changed. You must convert date when it is displayed but all these must be implemented in JS. i.e. you need a JS code which converts Gregorian date to Persian date. Also date must be converted back to Gregorian when it is sent back to the server.

Posted

Hi, Mr. Farshad

 

I can convert it to display in textbox, but when i click on calnedar button to view Jalali Calendar Panel, i cant triger this and jalali date send to panel and panel convert it to jalali agin and date is incorrect shown in then panel !!!

How can i trigger this when panel want get date from textbox i give it a grigorian date ?

 

If we have a OnGetText event like DBEdit or TField only for display a text not for store text in the DateTimePicker this is a best way for do it.

 

Can you help me for this event Please ?

 

Best Regrads

Posted

Hi Mr. Farshad

 

I Solved it with this code on OnAjaxEvent :

 

JSCode('document.getElementById("'+Self.JSName+'_id").value="'+GetJalaliDate+'";');

 

Thank you

 

Best Regards

  • Administrators
Posted

Hi Mr. Farshad

 

I Solved it with this code on OnAjaxEvent :

 

JSCode('document.getElementById("'+Self.JSName+'_id").value="'+GetJalaliDate+'";');

 

Thank you

 

Best Regards

 

Good. I will analyze your workaround and try to integrate it in framework if possible.

  • Like 1
Posted

Hi. Mr. Farshad

 

I develope this component with OnGetText event and work fine !

 

unit UniXJalaliCalendar;

interface

uses
 SysUtils, Classes, Controls, Ext, ExtPascal, ExtCalendar, uniGUIBaseClasses, uniGUIClasses, uniPanel,
 uniDateTimePicker, DateFunc;

Type TDateTimePickerGetText = procedure(sender: TObject; Var DisplayText: AnsiString) Of Object ;

Type
 TUniXJalaliCalendar = class(TUniDateTimePicker)
 private
FVersion: string;
OldOnAjaxEvent: TUniAjaxEvent ;
FOnGetText: TDateTimePickerGetText;
function GetJalaliDate: String;
Procedure OnMyAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings);
{ Private declarations }
 protected
{ Protected declarations }
Procedure Loaded; Override;
 public
{ Public declarations }
Constructor Create(Owner: TComponent); Override;
Destructor Destroy;
 published
{ Published declarations }
Property JalaliDate: String Read GetJalaliDate ;
Property OnGetText: TDateTimePickerGetText Read FOnGetText Write FOnGetText ;
 End;

procedure Register;

Implementation

// -----------------------------------------------------------------------------
Procedure Register;
Begin
 RegisterComponents('uniGUI Custom', [TUniXJalaliCalendar]);
End ;

// -----------------------------------------------------------------------------
{ TUniXJalaliCalendar }
Constructor TUniXJalaliCalendar.Create(Owner: TComponent);
Begin
 Inherited Create(Owner);
End ;

// -----------------------------------------------------------------------------
destructor TUniXJalaliCalendar.Destroy;
begin
 inherited;
End;

// -----------------------------------------------------------------------------
Function TUniXJalaliCalendar.GetJalaliDate: String;
Begin
 DateTimeToString(Result, 'yyyy/MM/dd', Self.DateTime) ;
 Result := StrMToSh( Result ) ;
End;

// -----------------------------------------------------------------------------
Procedure TUniXJalaliCalendar.Loaded ;
Begin
 Inherited;
 If WebMode Then
 Begin
	OldOnAjaxEvent := Self.OnAjaxEvent ;
	Self.OnAjaxEvent := OnMyAjaxEvent ;

	Self.Text := '' ;
 End;
End;

// -----------------------------------------------------------------------------
Procedure TUniXJalaliCalendar.OnMyAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings);
Var DisplayText : AnsiString ;
Begin
 If SameText(EventName, 'select') And ( Params.Values['Date'] <> '' ) Then
 Begin
If Assigned(FOnGetText)  Then
 	FOnGetText(Sender, DisplayText)
Else
 	DisplayText := GetJalaliDate ;
JSCode('document.getElementById("'+Self.JSName+'_id").value="'+DisplayText+'";');
 End;
 If Assigned(OldOnAjaxEvent) Then
OldOnAjaxEvent(Sender, EventName, Params);
End ;

// -----------------------------------------------------------------------------
End.

 

This code in AjaxEvent very important condition:

 

Params.Values['Date'] <> ''

 

 

Best Regrads

  • 4 years later...
Posted

To MainForm.Scrpits add:

 

Ext.override(Ext.DatePicker, {
  initComponent: Ext.DatePicker.prototype.initComponent.createInterceptor(function() {
	this.plugins = [Ext.ux.JalaliDatePlugin];
  	return(true);
	}) 
});
To ServerModule.CustomFiles add

 

files\Jalali\Jalali.js
files\Jalali\JalaliDate.js
files\Jalali\JalaliDatePlugin.js
files\Jalali\JalaliDatePlugin-fa_IR.js
This will change all DatePicker instances in your app to jalali calendar.

 

 

 

not work  loop loading ....

plz make sample code

Posted

Hi,

 

1. Download these files and copy to directory for example "files/":

  1.    https://raw.githubusercontent.com/behrang/Ext.ux.JalaliDatePlugin/master/Jalali.js
  2.    https://raw.githubusercontent.com/behrang/Ext.ux.JalaliDatePlugin/master/JalaliDate.js
  3.    https://raw.githubusercontent.com/behrang/Ext.ux.JalaliDatePlugin/master/JalaliDatePlugin-fa_IR.js
  4.    https://raw.githubusercontent.com/behrang/Ext.ux.JalaliDatePlugin/master/JalaliDatePlugin.js

* JalaliDatePlugin-fa_IR.js - for localization

 

2. UniServerModule.CustomFiles add these "lines":

files/Jalali.js
files/JalaliDate.js
files/JalaliDatePlugin.js
files/JalaliDatePlugin-fa_IR.js

3. UniDateTimePicker->ClientEvents->UniEvents ... add beforeInit fn:

function beforeInit(sender, config)
{
  sender.plugins = [new Ext.ux.JalaliDatePlugin]
}

Try...

 

post-906-0-43834600-1453094149_thumb.png

 

Best regards.

  • 5 months later...
Posted

Hi,

 

It is works, but

Follow this sequence:

 

1. UniDateTimePicker1->Kind = tUniDateTime

 

2. After,

UniDateTimePicker1->ClientEvents->UniEvents [Ext.form.field.Date[date]] ... date.beforeInit fn:

function date.beforeInit(sender, config)
{
    sender.plugins = [new Ext.ux.JalaliDatePlugin]
}

Best regards.

  • Upvote 1
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...