I want to change a single data from the table index which is stored in the database and not touching any data in the database. I just want the function in the button with a single click, without going through a Edit view in CRUD operation.
this is the data i want to change, thanks for any help.
Related
I have a cshtml view to perform crud operations on a client record. In the same view i want a data table to perform crud operations on children of each client , so one client can have multiple children. I want to add edit those child records however only when the entire client record is saved then the child record should be updated or created , deleted etc. Can i know if jquery datatable is the best for this , and how will i save child in memory and perform save all at once...thanks
Used javascript arrays, and hidden variables to make sure that added/edited data is not lost when posted back to controller .
You can load load the datatable child using Ajax (on click event of the client table). Then read all rows from the datatable child to get the data that you need.
yeah the question is: can mcv display on the details and index form the text data values vs just ID value that gets stored in the database .
It seems that mvc is very limited in what it can display to the screen. All of the demos and tutorials seem to stop short of showing this is a possibility most just show the user typing in the the full text value. So for example the user has a user interface form that has a list of values drop down element. THey click the value and the ID gets stored to the database.
Later on recall the user wants to pull the data back up for review... in mvc it seems you are stuck with displaying the ID field in the textbox.
but in most other systems you can make a datatable and return the text value of the field back to the form... Is this possible with MVC or are you limited to saving the full text value to the the database?
enter image description here
enter image description here
yeah the answer is: Make a view in SQL Server and then Link that View to the application via the EDMX. Details below.
Finally! I was able to figure out and I will post the solution so that it may help some one get around the mvc / normalized database limitation that seems to exist when you try to follow some of the tutorials.
The key is to build a SQL view outside of MVC. This can then be linked to the application and it will appear to be a table.
So if you use the database first method and you are using SQL server you will need to simply make a view in SQL server. This take mvcs out of the picture all and is much easier.
Step 1: Make a SQL view... that has everything you need joined in one big super view for what you need to display.
So in my case I made a sql server view that has the storage table linked to the support tables. Think of the query builder in MS Access where you link your tables to make a query.
You draw out your tables and links.
Add that to your Database First EDMX and in your controller use that new super view... and in your index and details forms you change the #model to your new super sql view and change the field name in the textboxfor... Boom problem solved... pretty swell how it all works... in this way you don't have to build some complicated view model. You just take the class that the wizard builds and then make a partial class to rename fields to give them user friendly names.
And you are no longer limited by mvc limitations
hope this helps!
I am using an editorfor template so that users can edit row information inline when the information is displayed as a table. The user then has a save button below the table which when pressed sends the whole Model to a HttpPost method which then iterates over each row and saves the row back to the database. As you can imagine this can become quite slow when the row number increases as it has to iterate over every row then save the information to the database.
I was looking for some way of saving a single row back to the database if a field is edited within that row or maybe setting a flag to true which when the user presses the save button it only iterates over the rows that have been edited and only saves those rows back to the database?
Any help would be much appreciated.
Regards,
Jay
Why you don't use Ajax to update each row?
You can associate the button to a javascript (jquery) function responsible to update (post) the modified row.
In this way you only update the modified row.
To avoid problems you can use a curtain or a spinner during the execution of the update.
Regards,
André
I am using Infragistics(Ignite UI) controls in my ASP.NET MVC3 application.
I have grid which I've bound to 'Customer' data. Works fine.
Now I have button. On clicking I make an ajax call.
In the controller I write query which selects only a part of 'Customer' data.
I return the data using json.
I try to re-bind it using:
$("#CustomerGrid").igGrid("dataSourceObject", returnData);
But the grid continues to show old data. It doesn't refresh.
Call the data bind method like so:
$("#CustomerGrid").igGrid("dataSourceObject", returnData);
$("#CustomerGrid").igGrid("dataBind");
or even like so:
$("#CustomerGrid").igGrid("dataSourceObject", returnData).igGrid("dataBind");
Just a general note - changing the data source can be extra overhead and generally not ideal solution. If I understand correctly you are replacing it with a part of the original collection? If the collection is big and/or you need to reset back to original state - perhaps consider simply returning id-s to the ajax call and use the Filtering feature?
Set the scene:
New to .NET; drinking from firehose
ASP.NET MVC app, SQL Server back
Editable table in browser with a single SAVE button.
User can right-click to add or delete rows.
Table won't ever have more than approx. 30 rows.
My question :
I'm saving everything upon the Save button click but would it be better to save row by row, AJAX style, as the user makes updates?
I don't like the look of separate buttons for each row, which is why I've designed it this way.
Is this mostly a UI issue? Am I missing any technical gotchas here, such as backend failure during the mass saving of the rows?
Additionally, assume I do save the entire table at once, is it better to create an ADO DataTable object or just loop through, inserting/updating each row as I go by calling a stored procedure. I suppose I could add LINQ to the firehose, but that would make this question even less "answerable".
You don't have a huge volume of data here, so saving all 30 rows at the end of the table is a reasonable approach. But you should be prepared for a failure, particularly if you are changing existing rows when it will fail more often due to other apps/users changing the same data. Just make sure that you wait for confirmation from the SQL server that the changes have been committed.
What I've done before with these sorts of big table views is when somebody clicks on a cell they'd like to edit, run some ajax to display a text field with that text, they can edit, then listen to onmouseout and the enter button to send off the ajax request to modify the single row.
When the response from the ajax call comes back you can add a tooltip or something that it was saved, and then change the cell to the new val.
Assuming you have SQL2005, you could build up an XML document with all of your data rows, then call a single stored proc and pass it your XML. Then the stored proc could save all of the rows at once.