FullCalendar - Prevent reloading of events from JSON source on month change - asp.net-mvc

Is there a way to prevent FullCalendar from re-fetching events from a JSON source when you change month?
The JSON source provides the initial list of events which can then be edited on the client side using: $('#calendar').fullCalendar('updateEvent', event); However changing month causes the events to be reloaded from the server, replacing the changed events with the original values.
I've tried setting stick to true in the event data from the JSON source, I've also tried setting cache to true when adding the event data source. I've left lazyFetching as true.
I guess a workaround would be to retrieve the JSON and add this as an array data source rather than a JSON data source..

No. There isn't a way to prevent refetching.
lazyFetch is for a smaller scope on the data that already cached (changing the view from month to week - the data is already in the client).
I'm not sure what you are trying to do.
how do you save changes when the user is happy?
I think the best practice in that case is to have a list of changes that uses both for a final approval when the user is happy and for re-rendering the calendar after the calendar re-fetch events when navigating.
add a listener to the refetch events and then change the events that the user changed earlier.

Related

Angular 11 Material DataSource without further Requests to the Server

I've been playing around with the example table-schematic for the Material Design [version: 11.0.3] table.
Basically i want to make a request, take the response and display it with the options to sort and limit the displayed items (pagination).
It works fine if I just replace the content of the connect function with "return a mapped Observable of the Response" but then the sorting and pagination obviously don't work anymore (since they are deleted) and i can't figure out how to make them work.
I assume the example pagination and sorting requires the data to be already present when the page loads/initializes (e.g. with a static Array).
Putting the request in the connect() function, saving the objects of the response to a variable and subscribing does work. However the page does not update after filling the initially empty array with data until sorting or pagination settings change. Which would make sense to me.
My question is, how do i get the data in there once and use the same data for pagination and sorting.
Can I even use the schematic in this case or is it misleading?
You can initialize a MatTableDataSource using an array of data, and then it will handle paging, filtering, and sorting locally and not try to fetch any more data.
See this example: https://stackblitz.com/angular/nleleddqmel?file=src%2Fapp%2Ftable-overview-example.ts
This example creates the data array locally, but you would instead use the response from your server request.

Firebase Database doesn't return value offline

I'm working on a app with Firebase Database and I also want to allow the user adding entries when he's offline. Imagine the following case (everything offline; it works perfectly online):
The user adds a client (shown in a main tableview - works)
On the detail view of the freshly added client, he adds an appointment with him. The appointments are listed in a tableview in the Client Detail ViewController.
When the appointment is added, the tableview isn't refreshed, because the callback doesn't call.
In code:
navCont.child = userDB.child(entityNameClients).childByAutoId()
navCont.child?.setValue(post) where post is a dictionary with the values of the customer
On the viewDidLoad Method of the detail view controller, I call the following code: getUsersDBReference().child(entityNameAppointments).child(clientKey).observe(.value). The Callback isn't called (probably because there are no elements in it)
Adding Appointment
var appointment:DatabaseReference
appointment = getUsersDBReference().child(entityNameAppointments).child(clientKey).childByAutoId()
appointment.setValue(appointmentDict)
The Callback of 2 isn't called (--> and the tableview not refreshed with the new appointment)
BTW, I set Database.database().isPersistenceEnabled = true in App Delegates applicationDidLoad-method.
And if I add the client online and go offline then, it works too.
Answer of Firebase Support:
The SDK attempts not to fire Value events with "partial" data. Since you are only updating a subnode of the location being observed, we don't have "complete" data and so the observer is not fired. If the SDK has ever had "complete" data for that node (e.g. because you overwrote the whole node or because you were previously online and got complete data for it), then it will fire events when you update it.
One workaround would be to use ChildAdded (and ChildChanged, etc.) events instead of Value.

What is the best way to save data online from UITableView?

My application
UITableView has 200 rows
In edit mode each cell has two actions for eg: passAction and failAction
After editing i want to update the database with either 0 or 1 based on its selection
I am retrieving data from server as json and storing it as object
Which is Best?
a. Requesting the server on each time the action is called.
b. Storing it in the local database and sync on completing all rows.
c. Request the server once on completion and send the whole object as JSON.
Help me in choosing the best option of implementation I can do!
Correct me if I bypassed any rules of SO because this is my first question!
#Dan Beaulieu: No need to send all data to server after edit. First update your database and Just send data which was changed in your database.
So add one field like "sync" in your database table and updated field set sync = 1 during edit and get data from database which was set sync = 1 and send it to server.

Observing changes to database value via KVO

I'm building a messaging application. I update the badge count in the database via a sqlite trigger whenever any operation like insert/delete/read message happens.
Currently, though the value update in the DB happens asynchronously, I have no way to get notified about when the value changes in my application and hence am polling periodically.
Is there some way to setup an observer on a database value/publish some notification when a given value changes?
I know that I can do this easily by first updating the badge count in an in-memory property and then persisting the changes to the DB; but I am not very inclined to do this, since there are too many entry points for this value to change, and I don't want to add a SET property everywhere.
One possible option would be to define a trigger that is only called when this specific value in the database is updated. The trigger should then make a call to a user defined function you create in your app. You use the sqlite3_create_function function to add your own function to SQLite. Your trigger would like something like:
CREATE TRIGGER some_trigger_name
AFTER UPDATE OF some_column ON some_table
FOR EACH ROW BEGIN
SELECT my_custom_fuction();
END;
If needed, you can pass 1 or more arguments to your function.
Though that this might not be an option for you, Core Data does this well.

Get previous value of an entity

I need to get previous value of an entity.
My requirement is like; I have some input fields in an edit page.
1 User can enter some values there and press save button at this time the user should be able to save it.
2 User can enter some values there and press Cancel button at this time the page should be reloaded with whatever values were there before the user start editing the page.
My question is that can entity frame work, help us in getting previous value of an object?
Is self tracking is something related to this?
You mentioned "page" so I guess you are talking about web application. In such case you should simply load entity from the database again because pushing Cancel button will make a new request to your web application. You should use a new context per request so you don't have any previous data or entity to reload - you will run a new query and get last data persisted to database.
What you would want to do is:
myContext.Refresh(RefreshMode.StoreWins, myObject);
This will ask the context to reload the entity removing any changes to the object and replacing the property values from the data store.

Resources