Can we write the JSON data locally to a file
Can we write the JSON data locally to a file
Hi Allan,
This may be one of the stupidest questions. Just as we can read from the local file as mentioned in the example( http://www.datatables.net/release-datatables/examples/ajax/ajax.html) -, I am testing it offline where HTML file and the JSON object array file resides locally, can we create and write to a file locally?
Regards
Joson
This may be one of the stupidest questions. Just as we can read from the local file as mentioned in the example( http://www.datatables.net/release-datatables/examples/ajax/ajax.html) -, I am testing it offline where HTML file and the JSON object array file resides locally, can we create and write to a file locally?
Regards
Joson
This discussion has been closed.
Replies
Regards
Joson
Allan
--allow-file-access-from-files file:///C:/offline/customer-search.html
[code]
"sAjaxSource": "customer/CustomerList.txt",
"bDeferRender": true,
[/code]
Regards
Joson
It seems the example is not working in Chrome 12. Only Print button gets enabled. Thanks
http://www.datatables.net/release-datatables/extras/TableTools/
Regarding your suggestion regarding passing the JSON data to the flash component, do you want me to add a new template to "tabletools.js" and pass the data?
Here is my thought process
a) each row has certain columns editable and when the user edits the value, he/she checks a box in the same row to indicate that he wants to save that edited values to the file ( done )
b) I need to loop through the data and save it silently to a file when user click on the button "Save Data" in the page.
c) I am planning to add one more button to TableTools.BUTTONS in the "tabletools.js" for saving the JSON data to the file.
Is this a correct approach? Please advise and thanks very much.
Regards
Joson
Is there a way to customize writing to the file without using the "oTableTools":aoButtons defined.
I mean I have a button called "Save" and in its click event, I am going through some selected rows and planning to write to the file. The place where I am getting stuck is
a) Is there a way to grab the flash movie clip instance to call fnSetText
b)Is there a way to write to the file to a directory without popping up the file open dialog box?
I would like to save to a file within the following code - would that be possible? Thanks
[code]
$('#savesomething', this).click( function () {
$.each(oTable.fnGetNodes(), function(index, value) {
if( $('input:checked', value).is(":checked") )
console.log( oTable.fnGetData(index, 0) + "\t" + oTable.fnGetData(index, 1) + "\t" +value.cells[2].innerHTML + "\t" +value.cells[3].innerHTML);
var tableTools = TableTools.fnGetInstance( 'example' );
//can I write to a file here???
});
});
[/code]
[code]
var tableTools = TableTools.fnGetInstance( 'example' );
var flash = new ZeroClipboard.Client();
flash.setAction( 'save' );
flash.setCharSet( 'UTF8' );
flash.setFileName( "filename.txt");
tableTools.fnSetText(flash, "Checking");
[/code]
Is there a way to specify a particular directory to save the files? Currently, it is defaulting to the directory where the html page resides? Thanks very much.
Also, it would be nice ( if it isn't already there) to save the file to a specific directory without prompting the user with File Save dialog box.
Regards
Joson
When you get a chance, could you take a look at my previous question/query. Thanks very much!!!
I'm planning on looking into the TableTools code a little more later this week, so I'll look for anything that might help you.
Regarding the file save dialog box that may be controlled by the flash/swf component and I think it may not be possible to save the file without the "File open/save" dialog box.
Regards
Joson
TableTools uses the FileReference ( http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html ) class in AS3, so whatever that can do, TableTools can (or could be modified to) do. It doesn't look like there is a way of doing either of the two things you want. Perhaps file an enhancement request against Adobe :-)
Allan
"The FileReference and FileReferenceList classes do not let you set the default file location for the dialog box that the browse() or download() methods generate."