Here I'm Using .net Core in Server Side and plain vanilla JavaScript for UI
AG grid is getting data from the SQL view thru ASP.net Core application.
in the Grid all the cells are editable. now i want to have one button on top of the Grid. if the user clicks that button only changed data needs to save in DB. is there any option to get oly dirt values or pls advice me how to achieve the above use-case.
Thanks in Advance.
I think there isn't such a complex solution implemented in ag-grid out of a box. But you can do it yourself with help of the events cellValueChange and/or rowValueChange (only if you are using editType = 'fullRow').
I suggest to use the scenario editType = 'fullRow'. So whenever the rowValueChange fires, store the new data of that row in some data array (of course, if a user edits the same row the second time, you need to overwrite the previous stored row value). And when the button is pressed, you pushed to the server only data of that changed rows you've collected.
Related
I am using the DataTables jQuery plugin with server side pagination to create a table with child rows where the user can change the data, the problem I have is when I move to another page without saving changes in the modified forms; the DataTables removes the rows and its child rows from the DOM, so I am not able to get later the updated rows to save the changes, also if I move back to the first page where the user modified the data, the child rows are re-created (as part of the createdRow event where I am creating the child rows) so the changes entered by the user are lost.
Is there any way to deal with this problem?
I don't have enough experience in working with DataTable, but I guess this plugin has something like "data is loaded" event. Before the page is reloaded, you can save your draft data in separate array/object (like draftData) and after data is loaded, you can merge information before page rendering.
I ended up creating my own logic since this is an expected behavior of the DataTables plugin.
When using server side with DataTables, the plugin doesn't have a way to identify or "remember" what rows are being modified, what rows are selected, etc. Because of each pagination request rebuild the table and re-create the rows.
I found somewhere that a valid approach was using a global variable to store all the changes (selected rows, updated data, etc) I am also using the createdRow event to restore the changes made by the user after creating each row.
I have a dropdown, on its change I need to load the contents related to it on the same page. Which I did using jQuery. Now the question is how do I make edits on this data and store it on my database. If I am wrong in using jQuery for loading my data then what else should I use? I am using PHP as my server side scripting language.
More detail -
Simply taking there a list of details I need to display as per the country you select, which I am displaying currently in a nice grid(textboxes)!
Now the data from this grid should be copied to another textbox on "EDIT" button click from where I edit them and store it in my database. I am not able to make the values copy into a another textbox
You could do this:
Display the data in some form of editable div, textarea, or other element.
Make a hidden field somewhere and when you display the data
Set the row id from your database to the hidden field
On your change event, grab the id from the hidden field along with the edited data.
Using Jquery/ajax, send that data to a php page that will save thee data to your database using the passed in id.
You could do that.
However, if it were me (and if you're not married to your current databse / mySQL etc..), I would use parse.com. The service is free up to a significant amount of usage (which Ive never come close to) and it really simplifies everything. See the below post if you're interested in that approach:
Save and retrieve user input from database with javascript?
I want to use ClientSide Javascript for listbox, it should take values from database table when the page is loaded first time OR load the specific table in javascript,
Right Now, all the values are coming from database, if I select "StandardM1(CA)"
it brings all the values from "food_menu" table.
I want to do the the same thing with client-side javascript in order to save time and server requests, so that the application runs faster.
Can some one please guide me?
Faheem use array in it and try to do the coding right on the save button. its the save button that is creating problems
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
I have a gridview and a dropdownlist on my page.
The gridview is binded through code behind with some columns. Among these price is also a column.
My scenario is to change the price field based on the dropdown criteria.
The price column consists of values in "lakhs", and i need to change them as crores or usd or some other format as per dropdown.
I don't want to go for postbacks. I want these to be implemented using javascript.
(These changes are for user conversion. They need not to be saved on database)
Thanks in advance
Madhu
You have two options. If you don't want to go for any response from the server (i.e. you don't want to make an AJAX call), you could populate a hidden field with a list of comma-delimited values that correspond to your dropdown values. It's an ugly approach, but it would work.
The other option is to make an AJAX call to a web method on the server (or possibly a financial service like Yahoo! Finance). When your dropdown selected value changes, that event fires a call to the server.
If you were able to indicate what platform you're using (PHP, .Net or other), someone will likely be able to provide more relevant examples and code samples.
Since the grid is rendered as an HTML Table, you can actually manipulate anything on the client.
I would pickup jQuery for the task