Right now I'm building a team based project with Node.js/MySQL/React and have been stuck at a ToDo list part. I would like to know what is the recommended or fastest way how to save data or options to database automatically and without any submit button on each row.
Todo item
You could do a single POST when adding a new row, and whenever you change the options you could do a PUT request, but as a general design rule I'd advise against it : you want to be able to review all your changes before committing them to the database, plus this requires a lot more requests, hence more controllers rather than just having one.
Looking at your screenshot why don't you have a single submit button at the bottom of the table ?
Related
I am writing a web app using PHP, MySQL, jQuery, and some miscellaneous add-ons like jEditable and DataTables. On most pages, the user will submit a form which will query the DB and bring back records matching my query rules. This works for 95% of my users 95% of the time. It's the other 5%/%% I am trying to help.
I am excluding records that are no longer being processed (completed/cancelled/accepted/rejected/etc.), leaving only "live" records. However, sometimes the leadership team needs to see the records I exclude. I could write a whole other page or report for each case, but that seems a huge waste of time.
Is there a way to add a "show all records" checkbox or button to my page? When clicked, the button would get and display the rest of the data, so users don't have to refresh/go to another page/etc.
you should add a toggle switch - it could be just a check box, or you could use something fancy like this: http://simontabor.com/labs/toggles/
Bind an event to it that preforms a table.ajax.reload() in datatables to pull in the new records. Also, for the datatables ajax request, provide a callback that returns the toggled state of the toggle control as a post variable, then handle the filtering in your sql on the back end.
Note, this solution means you will have to configure datatables to source data via ajax, which, from what you described sounds like you should be doing anyway.
I have HTML and JavaScript in place that allows a user to move Django database entries (displayed in a table) up and down. However, is there a way that I can store this new order that the user has customized so that it will show up any time the user navigates back to that specific page view? I think get_queryset is what is causing the page (after refreshing) to switch back to the basic filtering. But, I have no good ideas on how to override it or avoid it to accomplish this task. Any help would be much appreciated!
I would suggest using ready solutions: django-admin-sortable or django-admin-sortable2. As for me, I have successfully used second solution and it works. One important note about it is to run ./manage.py reorder my_app.models.MyModel after adding new order field as mentioned here.
I'm very new with JavaScript and I'm struggling to implement something which I don't think should be very complicated.
What I want to do is:
form is open in browser with a drop-down list of records in a database
if the desired option is not in the list, the user can click on a link next to it to add a new entry to the database
this will open a new window with an additional form for this entry
on clicking submit the processing script will run to insert this information into the database
when the processing script has completed, the window will close and the drop-down list will refresh so that it includes the new option (but without losing any other information in the form)
Maybe that last thing with the list refreshing is quite complicated (unless the list only in fact loads from the db on click?) but everything else should be simple enough, I think. I've tried all sorts of things but nothing that's got close enough to working to be worth posting here.
Could someone please give me some sort of idea of the sort of functions I should be using and roughly how to implement them? I don't necessarily need precise code, just a framework to work from. (I'll learn more in that case anyway.)
ETA: I should add that I've been trying to work with window.open() and window.close(). I don't even really know if this is the best method?
No, that's not(at least relatively) complicated. What you'll need is jQuery and jQuery UI(these frameworks are just suggestions, you may chose any other if you like) to achieve that. So...
form is open in browser with a drop-down list of records in a database
This part is easy, just a simple html form with a select tag and a add link/button on it. You will need a JavaScript function to refresh the select options from database. For that I suggest this or this -there are many others on the web- post.
if the desired option is not in the list, the user can click on a link
next to it to add a new entry to the database
this will open a new window with an additional form for this entry
The easy way to do this is using jQuery UI Dialog Widget to open the popup with the new form.
on clicking submit the processing script will run to insert this information into the database
On that form you'll have to use jQuery Ajax to send data to database through your server language(PHP, ASP.Net, JSP, whatever...). Some examples here and here.
when the processing script has completed, the window will close and the drop-down list will refresh so that it includes the new option (but without losing any other information in the form)
So when data processing was complete, you call the refresh select function that you created before and close the dialog on the ajax success callback. Example here.
And this is it. Now it's up to you. Hope it helps.
I am looking for a grid implementation on my dashboard. The requirement here is that if the data that the grid might be fetching changes while a user is looking through the grid, the changes should be reflected. So the row present in page 1 may be present in page 2 after sometime. If the user clicks on page 2, he should be shown a fresh page that is fetched from database and that item should be in page 2. So, I need to use a pagedObjectList to get the data and show that data when user looks for the next page. The same requirement is for sorting too.
So I am looking for a javascript Grid like jqGrid or DHTMLX grid or a Tag Library which has some sort of ajax calling mechanism for sorting and paging instead of showing the old data which is fetched first.
Please suggest any grid/ tag library implementation which can fulfill the above mentioned requirement. Thanks in advance
I finally went with DHTMLXGrid, it has all the configurable actions I needed, like onPageAction, onSort etc. I could simple write my custom code for those trigger events. I would also recommend it to others, pretty handy and solid.
I have a requirement to be able to update 'n' number of rows in one go.
I have acheived this by adding a SELECT into the column header of 1 particular column. This will give the user the option of picking a Yes/No option and making all subsuequent rows in said particular column in the grid view, the choice of Yes or No dependant on which the user chooses.
I have successfuly managed to do this. My problem is now sending the "New" updated row data to the server.
I have tried saveRow() with the row id of each row in the view. This does not do anything. No AJAX calls are made.
Can someone point me in the right direction?
Thanks
I write the answer only because you asked to point you in the right direction. Sending of the data from the local grid to the server is not complex (see here for example). The main problem is the case is concurrency.
In my opinion any web application should work not only as one user application. I wrote multiple answers (see here or here for example) where I described my opinion that one should better update modified rows directly after modification because of possible concurrency errors. The later the update take place the higher is the possibility that the same rows were already modified by another user from another computer. So I would recommend you to use standard saveRow behavior and send modified data directly after the modification.
I have solved this by simply making an AJAX call myself to the file that is declared in JQGrid. Passing all relevant data everything worked how I needed it to