Saving datatable content into a standalone serverside file

Please can you provide some sample on how to “save” the entire datatable content into a server side file (not database). (ex myfile.json, myfile.csv etc…). I think should be the inverse of webix/samples/15_datatable/01_loading/02_url_data.html

You can’t save data directly, as client side code doesn’t have access to file system, but you can send the data to server side, where one line script will save the data to file-system.

var state = dtable.serialize()
webix.ajax().post("save.php", { data: state });

Thank you, but unfortunatelly I could not find any PHP file in samples folder with this kind of operation. Could you please point for some sample/snnipet?

I write the code bellow and its working. Please can you validate or suggest better script option?

<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $filedata = $_POST['data']; if (empty($filedata)) { echo "data is empty"; } else { echo $filedata; } } else echo "error"; ?>

Yep, you can just read $_POST[“data”] to get serialized state of the grid.

file_put_contents("data.json", $_POST["data"]);