Jump to content

I can't show ShowMask


yakup

Recommended Posts

Hi,

I save databasee UniCalendarPanel1 events and  in form.onshow Load from database. 

Now the data has grown,  it takes a long time.

 

I want show message before installation after hide message. but not :(
 

procedure TMainForm.LoadEvents;
var
  mq: TMyQuery;
  ce: TUniCalendarEvent;
  i: integer;
begin
  UniCalendarPanel1.ShowMask('Ajanda Bilgileri Yükleniyor...');
  // UniSession.Synchronize;
  UniCalendarPanel1.Events.Clear;

  mq := TMyQuery.Create(nil);
  try
    mq.Connection := MyDataModules.MyConnection;
    mq.sql.Clear;
    mq.sql.Add('SELECT * FROM unicalendarevent ua WHERE ua.User=:user AND Deleted=0');
    mq.ParamByName('user').AsString := UniMainModule.username;
    mq.Open;
    while not mq.Eof do
    begin
      ce := UniCalendarPanel1.Events.Add;
      ce.EventId := mq.FieldByName('EventId').AsInteger;
      ce.CalendarId := mq.FieldByName('CalendarId').AsInteger - 1;
      ce.Title := mq.FieldByName('Title').AsString;
      ce.StartDate := mq.FieldByName('StartDate').AsDateTime;
      ce.EndDate := mq.FieldByName('EndDate').AsDateTime;
      ce.Location := mq.FieldByName('Location').AsString;
      ce.Notes := mq.FieldByName('Notes').AsString;
      ce.IsAllDay := mq.FieldByName('IsAllDay').AsBoolean;
      ce.Url := mq.FieldByName('Url').AsString;
      ce.Reminder := Ifthen(mq.FieldByName('Reminder').AsBoolean, '1', '0');
      ce.IsNew := mq.FieldByName('IsNew').AsBoolean;
      ce.Description := mq.FieldByName('Description').AsString;
      mq.Next;
    end;
  finally
    if Assigned(mq) then
      FreeAndNil(mq);
    UniCalendarPanel1.HideMask;
  end;
end;

 

Link to comment
Share on other sites

2 hours ago, yakup said:

I want show message before installation after hide message. but not :(

Hello,

This approach may help you:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniCalendarPanel1.JSInterface do
  begin
    JSAddListener('afterrender', 'function(me){me.getStore().on("beforeload", function(){me.showMask("Please wait...")}); me.getStore().on("load", function(){me.hideMask()})}');
  end;
end;

 

Link to comment
Share on other sites

5 minutes ago, Sherzod said:

Hello,

This approach may help you:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniCalendarPanel1.JSInterface do
  begin
    JSAddListener('afterrender', 'function(me){me.getStore().on("beforeload", function(){me.showMask("Please wait...")}); me.getStore().on("load", function(){me.hideMask()})}');
  end;
end;

 

 

It's the entire form, how can I make it just a calendar?

Link to comment
Share on other sites

3 minutes ago, yakup said:

how can I make it just a calendar?

//me.showMask("Please wait...", me)

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniCalendarPanel1.JSInterface do
  begin
    JSAddListener('afterrender', 'function(me){me.getStore().on("beforeload", function(){me.showMask("Please wait...", me)}); me.getStore().on("load", function(){me.hideMask()})}');
  end;
end;

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, yakup said:

The mask closes before the list arrives.

Well, this is expected, this event does not wait for “redrawing” in the calendar itself.

 

"Workaround"

1. 

UniCalendarPanel1.JSInterface.JSAddListener('afterrender', 'function(me){me.getStore().on("beforeload", function(){me.showMask("Please wait...", me)}); me.getStore().on("load", function(){ajaxRequest(me, "_load", {})})}');

2. 

procedure TMainForm.UniCalendarPanel1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_load' then
    (Sender as TUniCalendarPanel).HideMask;

end;

 

Link to comment
Share on other sites

3 hours ago, yakup said:

It is visible for 2.20 seconds after the mask creation process then gone. Data appears 2.74 seconds after mask disappears

Well, you can use Ext.defer for example:

1. Ext.defer(function(){ajaxRequest(me, "_load", {})}, 3000)

UniCalendarPanel1.JSInterface.JSAddListener('afterrender', 'function(me){me.getStore().on("beforeload", function(){me.showMask("Please wait...", me)}); me.getStore().on("load", function(){Ext.defer(function(){ajaxRequest(me, "_load", {})}, 3000)})}');

2. 

procedure TMainForm.UniCalendarPanel1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_load' then
    (Sender as TUniCalendarPanel).HideMask;
end;

 

Link to comment
Share on other sites

Just now, yakup said:

Bad idea, I don't like static definitions at all. What will happen if it comes in 10 seconds instead of 3 seconds in the future?

You may be right, although I don’t think it will be directly proportional to the number of records.

By the way, you can test on slightly larger amounts of data.

 

5 minutes ago, yakup said:

Bad idea

I'll try to analyze it further.

  • Like 1
Link to comment
Share on other sites

1. Remove "previous codes".

2. UniCalendarPanel.ClientEvent.ExtEvents ->

function afterrender(sender, eOpts) 
{
    sender.getStore().on("beforeload", function() {
        sender.getView().activeView.setLoading("Please wait...")
    });
}

3. MainForm.Script ->

Ext.calendar.view.Weeks.override({
    constructEvents: function() {
        this.callParent(arguments);
        if (this.ownerCt.isMasked()) {
            this.ownerCt.setLoading(false)
        }
    }
});

Ext.calendar.view.Days.override({
    constructEvents: function() {
        this.callParent(arguments);
        if (this.ownerCt.isMasked()) {
            this.ownerCt.setLoading(false)
        }
    }
});

 

  • Like 1
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...