EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: dustinjo on February 24, 2014, 08:53:10 PM



Title: How to import json data into datagrid in the memory
Post by: dustinjo on February 24, 2014, 08:53:10 PM
I'm not sure if here is the correct place for my question.
I would like to purchase the license of a product, and I need to know if it is possible for my project.

1. Is it possible to import the json data into datagrid in the memory?
2. How do I retrieve data in the datagrid by button click event instead of having it appear automatically?
3. How do I use file upload process?

Thank you.


Title: Re: How to import json data into datagrid in the memory
Post by: stworthy on February 24, 2014, 11:58:45 PM
1. Set the 'data' property to load local data or 'url' property to load remote data.
Code:
$('#dg').datagrid({data:...});  // load local data
$('#dg').datagrid({url:...});   // load remote data
2. Call 'getData' or 'getRows' methods to return the data bound to datagrid.
Code:
var data = $('#dg').datagrid('getData');
console.log(data);
var rows = $('#dg').datagrid('getRows');
console.log(rows);
3. To upload a file, declare a form with enctype set to 'multipart/form-data' and then call 'submit' method of form to upload the file.
Code:
<form id="fm" action="..." enctype="multipart/form-data" method="post">
  <input type="file" name="file">
  <input type="button" onclick="javascript:$('#fm').form('submit')">upload</input>
</form>