jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Export grid data to csv when click on save button?
Tagged: jqxgrid, jqxwidgets
This topic contains 2 replies, has 2 voices, and was last updated by ivailo 9 years, 9 months ago.
-
Author
-
Hi Team,
I have a grid data and i edit those. Once all the cells are edited, i need to save it. Once save button is clicked, it should save the entire data in csv file. This csv file is located in the server with url provided of where the file is.how can i save this grid data to backend csv file. I dont want to save one single row or column but the entire grid.
I read this in one of the comments
{
var exportInfo;
$(“#excelExport”).click(function () {
exportInfo = $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’);
});
}It saves the entire grid data in a variable ‘exportInfo’. should i use this to export data to csv ?
Please note: i am loading the csv data first and all the contents of the file are loaded in the grid by using datatype:csv.
should i mention datatype:json and then bring in data ? i eventually need to put data back to csv and i am not getting how to do that.There are these below functions already added. But i donot want to addrow, updaterow or deleterow. i want to save entire grid data itself after editing.
{
updaterow: function(rowid, rowdata, commit) { // synchronize with the server – send update command
// call commit with parameter true if the synchronization with the server is successful
// and with parameter false if the synchronization failder.
commit(true);
},
addrow: function(rowid, rowdata, position, commit) {
// synchronize with the server – send insert command
// call commit with parameter true if the synchronization with the server is successful
//and with parameter false if the synchronization failed.
// you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB.
commit(true);
},
deleterow: function(rowid, commit) {
// synchronize with the server – send delete command
// call commit with parameter true if the synchronization with the server is successful
//and with parameter false if the synchronization failed.
commit(true);
},
}In case you want me to use this,
var exportInfo;
$(“#excelExport”).click(function () {
exportInfo = $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘xls’);
});and send data via Ajax to the server. how can i ensure that this send data will save all the grid data to csv file ??
Hi ashwin prabhu,
Use
exportInfo = $("#jqxgrid").jqxGrid('exportdata', 'csv');
if you want to export to csv file.
Here are all export types – ‘xls’, ‘xml’, ‘html’, ‘json’, ‘pdf’, ‘tsv’ or ‘csv’.
exportdata will convert to csv all the data from your table. Then you have to create your backend script to save the data on the server.
The server script may vary, depending of your needs.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.