Forum > Packages and Libraries

[solved] tvPlanit - deleted event is still there

(1/1)

Nicole:
There is a search function (to my mind it works fine), which gives me the number of the event, which shall be deleted.

The deletion event looks like this.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// deletes an event from tfPlanit by numberprocedure TTvPlanItFrame.LoescheEvent(Nr: integer);Var res: TVpResource;    event: TVpEvent;    i: Integer; begin  res := VpControlLink_my.Datastore.Resource;    // war VpControlLink1  if res = nil then exit;   for i := 0 to res.Schedule.EventCount-1 do  begin    if i = Nr then begin      event := res.Schedule.GetEvent(i);      res.Schedule.DeleteEvent(event);      break;    end;  end; end
After having called the method, I close down the tvPlanit-software and re-open it.
I had expected that the deleted events would be gone.
However, these events are still there.

What can I do?

wp:
Call Datastore.PostEvents after deleting the resource from the Schedule.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.LoescheEvent(Nr: integer);Var  res: TVpResource;  event: TVpEvent;begin  res := VpControlLink1.Datastore.Resource;  if res <> nil then   begin    event := res.Schedule.GetEvent(Nr);    res.Schedule.DeleteEvent(event);    VpIniDatastore1.PostEvents;  end;end;
BTW, no need to iterate over all events to find the one with the given index Nr.

And I just added an overloaded DeleteEvent to the Schedule which has the event index as parameter so that above code can be rewritten as:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.LoescheEvent(Nr: integer);Var  res: TVpResource;begin  res := VpControlLink1.Datastore.Resource;  if res <> nil then   begin    res.Schedule.DeleteEvent(Nr);    VpIniDatastore1.PostEvents;  end;end;

Nicole:
Thank you for your answer, I wrote this now, - hm, but it does not work.
At the moment I have listed 3 event by my filter.
Hitting "delete" with the method below, makes vanish one line of those three (which may be a mistake in my loop as well).
The pre-problem is: Closing my software and re-open it makes those three lines re-appear. So there may be "deleted" one event, but this seems not to be saved back into the ini-datastore.

If you want it, I can zip my whole software and give you the filter criteria.
If not, here is the method, which makes
- vanish one of wanted 3 events (my be my mistake)
- restores this event again on re-start of the program



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// löscht ein Event aus TvPlanner, und bei "false" auch aus meinen Dateienprocedure TTvPlanItFrame.LoescheEvent(Nr: integer; nur_aus_tvPlanit: Boolean =  true);Var res: TVpResource;    event: TVpEvent;    KategorieNr: Integer;    datum: TDateTime;    beschreibung: string; begin  res := VpControlLink_my.Datastore.Resource;    // war VpControlLink1  if res <> nil then      begin        event:=res.Schedule.GetEvent(Nr);        res.Schedule.DeleteEvent(event);        VpControlLink_my.DataStore.PostEvents;        if not nur_aus_tvPlanit then begin  // this is false and shall not matter           event:=res.Schedule.GetEvent(Nr);           datum:=event.StartTime;           beschreibung:=event.Description;           KategorieNr:=event.Category;           Erfolg.LoescheTerminAusDatei (datum, beschreibung, KategorieNr);      end; end;end;  

wp:
I am attaching a simple demo project in which you can delete all events of today by a button click (when you test this make sure to add some dummy events for "today" before you do this). It is working for me. If it is not working in your project you must have some logic error along the way. One possible candidate: Do you iterate the deletion loop downward?

Nicole:
Thank you so much!

and: I am glad to have learned about the searching by data functionality besides.

Navigation

[0] Message Index

Go to full version