EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: ajhalls on February 26, 2014, 09:10:27 PM



Title: Save to JSON File
Post by: ajhalls on February 26, 2014, 09:10:27 PM
Please forgive me for a stupid question. While I was looking at jeasyui it came with some sample data in a json file. When I was using the inline editor feature, it wouldn't save it even with 777 permissions, I checked the access and error logs but there wasn't any entry to indicate it tried and failed.

I am also hoping to use a json file to perhaps drive the configuration of my grid so that on installation it has some default values and works right out of the box, but then I can edit it for mysql connection information options and such in a grid format and save it. Basically I want to setup the config.php type settings by using a grid setup using a tree configuration so you can collapse and expand sections. For very simple usages, they might even be able to get away with only using a json and never connect with mysql (I don’t know, I am not an awesome developer[yet]).

I was trying to combine the Editable Treegrid and the Treegrid with ContextMenu and couldn't find a way to configure a save button for it from the examples. There is a great example for the regular datagrid, but the Treegrid with ContextMenu can't be saved with the code in the example (that I am aware of) to the mysql.


Title: Re: Save to JSON File
Post by: stworthy on February 27, 2014, 01:28:23 AM
When call 'endEdit' method to end a editing row, the row data is only updated in memory, you have to post the updated row to remote server manually. The code below shows how to end editing a treegrid row and save it to the remote server(maybe a mysql database).
Code:
var id = ...  // the node id
$('#tg').treegrid('endEdit', id);
var row = $('#tg').treegrid('find', id);  // find the row data
$.post(yoururl, row, function(result){  // post the row to remote server
  //...
});