yakup Posted December 8, 2023 Share Posted December 8, 2023 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; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 8, 2023 Share Posted December 8, 2023 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; Quote Link to comment Share on other sites More sharing options...
yakup Posted December 8, 2023 Author Share Posted December 8, 2023 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? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 8, 2023 Share Posted December 8, 2023 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; 1 Quote Link to comment Share on other sites More sharing options...
yakup Posted December 8, 2023 Author Share Posted December 8, 2023 thanks a lot 1 Quote Link to comment Share on other sites More sharing options...
yakup Posted December 8, 2023 Author Share Posted December 8, 2023 1208(1).mp4 there is a problem , The mask closes before the list arrives. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 8, 2023 Share Posted December 8, 2023 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; Quote Link to comment Share on other sites More sharing options...
yakup Posted December 11, 2023 Author Share Posted December 11, 2023 Unfortunately, the mask is removed before the event comes again. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2023 Share Posted December 11, 2023 30 minutes ago, yakup said: the mask is removed before How much earlier? Do you have a lot of events? Quote Link to comment Share on other sites More sharing options...
yakup Posted December 11, 2023 Author Share Posted December 11, 2023 102 pieces, not that many. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2023 Share Posted December 11, 2023 7 minutes ago, yakup said: 102 pieces, not that many. How much earlier does the mask disappear (how many seconds) !? Quote Link to comment Share on other sites More sharing options...
yakup Posted December 11, 2023 Author Share Posted December 11, 2023 It is visible for 2.20 seconds after the mask creation process then gone. Data appears 2.74 seconds after mask disappears Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2023 Share Posted December 11, 2023 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; Quote Link to comment Share on other sites More sharing options...
yakup Posted December 11, 2023 Author Share Posted December 11, 2023 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? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2023 Share Posted December 11, 2023 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. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 12, 2023 Share Posted December 12, 2023 7 hours ago, 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? It seems I have found one optimal solution. Quote Link to comment Share on other sites More sharing options...
yakup Posted December 12, 2023 Author Share Posted December 12, 2023 1 minute ago, Sherzod said: It seems I have found one optimal solution. I wonder what it is Quote Link to comment Share on other sites More sharing options...
yakup Posted December 12, 2023 Author Share Posted December 12, 2023 Actually, it would be great if my code worked correctly. UniCalendarPanel1.ShowMask('Ajanda Bilgileri Yükleniyor...'); work(); UniCalendarPanel1.HideMask; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 12, 2023 Share Posted December 12, 2023 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) } } }); 1 Quote Link to comment Share on other sites More sharing options...
yakup Posted December 12, 2023 Author Share Posted December 12, 2023 I will try now. 1 Quote Link to comment Share on other sites More sharing options...
yakup Posted December 12, 2023 Author Share Posted December 12, 2023 It was exactly what I wanted. thank you. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.