What is the best solution to check if dataset has been changed (added / edited ,deleted records)? - javascript

I'm working on a project where the user has to be able to add or edit hours that he will work or worked. The dataset I'm using for this I retreive from ASP.net / MVC 4. What is the best way to check if the user added new data to the table or edited some data?
Example: The user loads the page, the calender is set to the current date --> table shows 3 weeks. Previous week, this week and next week. The dataset load in the hours that were retreived from ASP.net. The user adds new hours and edits some hours. Then the user clicks on the button to go to the next week. The data entered by the user has to be compared with the retreived dataset. The dataset has to be saved, this will happen in ASP.net. But after the save the browser gets the data of the next week and the calendar has to be for the next week.
The data added / edited by the user has to be saved but I have to know if this is edited or added. What is the best way to do this?
The retreived dataset = a string? Could I compare this by just comparing 2 strings? remove enters, spaces, ...
Is there a library to compare datasets in jquery?
To show the next week I think the page cannot be refreshed? Correct?
Any other suggestions are welcome.

I'm not quite sure on what you're going at here, however a suggestion might be to either have a save button on each page or hook up a event for whenever the input looses focus (or whatever you're using for selecting hours etc).
For the latter suggestion it would require more javascript, for example each input that's rendered could have data attributes of which year, month, and day it represents so it can be used when posting a change.
If you however prefer to submit the whole "dataset", you should checkout modelbinding if you're not already fimiliar with it, then either post the collection when clicking save or changing page.
Scott Hanselmans article on how the default modelbinder works might be of any help.

Related

DatePicker or Textbox in HTML

I am new to programming and I am working on a web application using JAVA EE, struts, jsp, HTML,
I have a table which shows some statistics and my client wants me to add a feature to pick a back date to see that dates statistics, but I am totally confused.
I had pre built queries which were getting data from oracle database and displaying data on my table on a JSP page. But now I change my query to a prepared statement and I have added a "?" to get a date from user and then replace that and make a query and display data.
First problem is that which struts when you have values to be displayed and they have some sort of problem the table won't even show up and secondly when I try to pick a date and hit submit button it should go make the query and display the table but it is not happening, I am totally lost. I will be grateful if someone can tell me how to solve this problem.
Thanks.

Attempting to create a calender with a clock picker built into each day as an ng-click

I understand that this sounds a bit far fetched but i want to build a monthly calendar that when the day is clicked it is routed to another page that then prompts the user to put in a start and end time which the program then calculates the total amounts of hours and assigns it to the original calendar. I have found a few j query plugins however when combined or any of their code is manipulated they both seem to break. If you have any suggestions anything is welcomed. I can upload what i have for code so far but its not really flushed out or good at all.

FullCalendar does not display past events. How to store lastCreatedEvent date?

Whenever i insert an event and that day passes it just disappears from my calendar. I have a different page where i load all the events and they're still there so they are not being removed from the database.
There must be a check somewhere in the FullCalendar code which makes it that it doesn't display dates < $today. I have no clue on where to start looking, is there anyone who had the same problem as me? How did you manage to fix it? Thank you for reading my question.
Also, how would i go about storing the last created event day? For example, i want to create a function which brings the users to my event created in August instead of today's date.
$('#calendar').fullCalendar( 'gotoDate', LASTCREATEDDATE );
I need it to update whenever somebody creates a new event.
I looked for different functions on how to achieve this but i'm not quite sure how to do this.
Your problem is that you are not getting the right events to be showed.
As you can read here FullCalendar is going to send the following URL to the server:
/myfeed.php?start=2013-12-01&end=2014-01-12&_=1386054751381
So you have to select from your database the events which EventStartDate <= end && EventEndDate >= start
About your second question you should use something like SignalR or WebSockets if you want the calendar of your users to be updated as soon you create a new event.

Planning tool JQuery / MVC 4

The webapplication I would like to build gives the user the possibility to select a period on a calendar. On the selected days they can write the start and end hour. The total amount of hours gets calculated. On the image below you can see what I would like to accomplish. What is a good way to get started programming this? Is there a good tutorial to get me started?
Is there a JQuery widget that gives a good start?
On the left you got some Employees and for each of them the user can select the period and fill in the hours they have to work.
I hope u get the idea that i have in mind. Please feel free to ask me any specifications.
I'm using MVC 4 - razor pages for the webapp
Thanks in advance
I've made something very similar in a MVC2 app with jQuery to check schedules for formative actions.
I first place a temporary span for the action and load it into the calendar provided by jQuery's datepicker, later I overwrite it's onSelect event to affect and save my data.
So when I click on a day of the calendar (only days on the previously selected time span are clickable) I allow user to introduce data for the schedule on that day.
Data saving to server is managed through AJAX calls that saves during using interaction.

Adding a new row to a dynamic ASP.NET Table Control, at position x - Problems with Viewstate after postback

I am creating a dynamic table control with ASP.NET/C# and the table is being used to hold a form. I need to allow users to click on a button in a row and make a duplicate of that row right below the original. My page is also using AJAX and jQuery.
I have tried to use Table.Rows.AddAt(indexoforigrow+1, newrow) but I get an error that the index is out of the range of values. I figured maybe I wasn't getting the original row's index correctly so I just tossed in a 1 and still got the error.
I also noticed that when I press the button to execute the code, the table disappears. Any ideas on how to fix that?
I am thinking that if I am unable to get these issues fixed I will have to loop through the table and submit the data to a temp table, adding a new row where indicated. Then I would pull all of the data back out and display again.
EDIT
I moved on when I could not get this working and tried to setup my submit functions to loop through the data and submit it to a db and realized that I am experiencing the same issues when clicking the submit button as when I click the add row button. It appears that my issue is really with viewstates/postback.
I did some reading on this and from what I can tell the solution is to re-create the dynamic control on page load every time. But I am confused about how I can do this if I have no idea how many rows/cells I have and how is the information the user entered kept in the form? I have no way of saving the information to a DB or anything because as soon as submit is clicked it all disappears.
Have you considered using a different control? One of the grid controls might better serve your purpose.
I've handled situations (that sound) similar to what you're describing by using the footer of a GridView (among other ways). The big trick is to bind the display object (Table, GridView, etc.) to a list of objects. Then you manipulate the list of objects, rebinding the display object after the list has changed.
You will need to persist this list in some manner, or you could wind up with the list being reset to null. One way would be to save it as part of the session.
At any rate, the idea is to have a display object (GridView) bound to a list of objects. When the user clicks 'add', an item is added to the list. Save the list, then call the GridView.DataBind method.
You are on the right track with re-creating the dynamic table each time the page loads. I have dome similar things and my solution was to keep a client state in a hidden field on the page. Every time you add a row to the table on the client, increment a counter or adjust the state data in the hidden field. Then, on the server-when the page posts back, read from that hidden field to know how many rows were added on the client. You will have to use some kind of naming convention for the new rows you add(and the widgets in them) so you can re-create them on the server.
A simpler option may be to use an UpdatePanel. Rather than try to add the rows on the client, your "add row" button would cause a partial update. The server side code would add the new row to the table and the viewstate would be updated.
I ended getting my data guy to do a bit more processing on his end so that I could just bind a ListView to a sproc. Solved a few of my problems.
Thanks for the helpful comments.
Just returning to this almost a year later because I faced a similar issue in my current project. I was doing a few things wrong my first time around. First, I did indeed need to recreate the controls every load, but I also had to create them earlier in the page cycle. I was trying to create them during page load, which is after the viewstate is loaded.
The controls need to be recreated with the same ID before viewstate is loaded. I went with page init and it worked fine.

Categories