Jump to content

How to insert JS code in pascal ?


Luciano França

Recommended Posts

This example how could I do ?

I tried this but it doesn't work

 With UniDBTreeGrid1.ClientEvents.ExtEvents do begin
  Clear;

  Add('function store.load(sender, records, successful, operation, eOpts)');
  Add('{  var me=sender;  me.remoteSort=false; ');
  Add('  me.sort({property:0, direction:"ASC"}); }');
 End;

 

Link to comment
Share on other sites

Yes I have an old account

now I have just joined the unigui team with the purchase of a Unigui Professional license.

I'm sorry but I use Google translator

let's go to the question how could I do it by pascal code ?

 

 

With UniDBTreeGrid1.ClientEvents.ExtEvents do begin
  Clear;

  Add('function store.load(sender, records, successful, operation, eOpts)');
  Add('{  var me=sender;  me.remoteSort=false; ');
  Add('  me.sort({property:0, direction:"ASC"}); }');
 End;
Link to comment
Share on other sites

19 hours ago, luapfr said:

now I have just joined the unigui team with the purchase of a Unigui Professional license.

Hello, thank you.

19 hours ago, luapfr said:

let's go to the question how could I do it by pascal code ?

With UniDBTreeGrid1.ClientEvents.ExtEvents do begin
  Clear;

  Add('function store.load(sender, records, successful, operation, eOpts)');
  Add('{  var me=sender;  me.remoteSort=false; ');
  Add('  me.sort({property:0, direction:"ASC"}); }');
 End;

What exactly do you want to achieve?

Link to comment
Share on other sites

32 minutes ago, Sherzod said:

Use it in the form's OnCreate event.

I just tried and the page just keeps loading...


  something is wrong please see my code

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
 With UniDBTreeGrid1.ClientEvents.ExtEvents do begin
  Clear;

  Add('function store.load(sender, records, successful, operation, eOpts)');
  Add('{  var me=sender;  me.remoteSort=false; ');
  Add('  me.sort({property:0, direction:"ASC"}); }');
 End;
end;


 

Link to comment
Share on other sites

8 hours ago, Sherzod said:
UniDBGrid1.ClientEvents.ExtEvents.Values['store.load'] := 'function store.load(sender, records, successful, operation, eOpts){var me=sender; me.remoteSort=false; me.sort({property:0, direction:"ASC"});}';

 

How could I do if the component is created in RunTime

See this code below does not work
 


procedure TMainForm.UniBitBtn1Click(Sender: TObject);
Var UniDBTreeList: TUniDBTreeGrid;
begin

 UniDBTreeList := TUniDBTreeGrid.Create(Self);

 UniDBTreeList.DataSource := DataSource2;

 UniDBTreeList.ClientEvents.ExtEvents.Values['store.load'] :=
  'function store.load(sender, records, successful, operation, eOpts){var me=sender; me.remoteSort=false; me.sort({property:0, direction:"ASC"});}';

 With UniDBTreeList do Begin
  Parent := Self;
  Left := 27;
  Top := 48;
  Width := 250;
  Height := 250;
  Hint := '';
  Font.Color := clBlack;
  Font.Height := -15;
  Font.Name := 'Arial';
  ParentFont := False;
  LoadMask.Message := 'Loading data...';
  UseArrows := True;
  IdParentField := 'PARENTID';
  IdField := 'ID';

  with Columns.Add as TUniBaseDBGridColumn do Begin
   FieldName := 'MENU_ITEM';
   Title.Caption := 'Menu';
   Title.Font.Charset := ANSI_CHARSET;
   Title.Font.Height := -15;
   Title.Font.Name := 'Arial';
   Width := 421;
   Font.Charset := ANSI_CHARSET;
   Font.Color := clBlack;
   Font.Height := -15;
   Font.Name := 'Arial';
   ReadOnly := True;
  end;
 end;
end;

 

Link to comment
Share on other sites

55 minutes ago, luapfr said:

UniGui ExtEvents.7z 32.89 kB · 0 downloads

Try this approach for now:

  //UniDBTreeList.ClientEvents.ExtEvents.Values['store.load'] :=
  // 'function store.load(sender, records, successful, operation, eOpts){var me=sender; me.remoteSort=false; me.sort({property:0, direction:"ASC"});}';

  UniDBTreeList.JSInterface.JSAddElListener('load', 'store', UniDBTreeList.JSInterface.JSFunction('', 'var me=this; me.remoteSort=false; me.sort({property:0, direction:"ASC"});'));

 

Link to comment
Share on other sites

46 minutes ago, Sherzod said:

Try this approach for now:

  //UniDBTreeList.ClientEvents.ExtEvents.Values['store.load'] :=
  // 'function store.load(sender, records, successful, operation, eOpts){var me=sender; me.remoteSort=false; me.sort({property:0, direction:"ASC"});}';

  UniDBTreeList.JSInterface.JSAddElListener('load', 'store', UniDBTreeList.JSInterface.JSFunction('', 'var me=this; me.remoteSort=false; me.sort({property:0, direction:"ASC"});'));

 

 

It works Much obliged.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
On 1/2/2023 at 10:12 PM, Sherzod said:
UniDBGrid1.ClientEvents.ExtEvents.Values['store.load'] := 'function store.load(sender, records, successful, operation, eOpts){var me=sender; me.remoteSort=false; me.sort({property:0, direction:"ASC"});}';

 

Hello!

Is this code is correct for UniForm (create dynamically)?:

procedure TUniFrame1.DynamForm;
var
  f: TUniForm;
begin
  f:=TUniForm.Create(UniApplication);
  f.ClientEvents.ExtEvents.Values['window.show']:=
      'function window.show(sender, eOpts) {' +
      'var el = sender.getE1(); ' +
      'el.setOpacity(0); ' +
      'el.fadeIn({duration: 1000});}';
end;

 

Link to comment
Share on other sites

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...