jQuery UI Widgets Forums Grid Export data from json data

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Peter Stoev 11 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Export data from json data #31217

    nguyentran
    Member

    Hi.
    i have 1 file php return json same :

    <?php
    #Include the connect.php file
    include('connect.php');
    #Connect to the database
    //connection String
    $connect = mysql_connect($hostname, $username, $password)
    or die('Could not connect: ' . mysql_error());
    //Select The database
    $bool = mysql_select_db($database, $connect);
    if ($bool === False){
    print "can't find $database";
    }
    if (isset($_GET['update']))
    {
    // UPDATE COMMAND
    $update_query = "UPDATE `employees` SET `FirstName`='".$_GET['FirstName']."',
    `LastName`='".$_GET['LastName']."',
    `Title`='".$_GET['Title']."',
    `Address`='".$_GET['Address']."',
    `City`='".$_GET['City']."',
    `Country`='".$_GET['Country']."',
    `Notes`='".$_GET['Notes']."' WHERE `EmployeeID`='".$_GET['EmployeeID']."'";
    $result = mysql_query($update_query) or die("SQL Error 1: " . mysql_error());
    echo $result;
    }
    else
    {
    $pagenum = $_GET['pagenum'];
    $pagesize = $_GET['pagesize'];
    $start = $pagenum * $pagesize;
    $query = "SELECT SQL_CALC_FOUND_ROWS * FROM employees LIMIT $start, $pagesize";
    $result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
    $sql = "SELECT FOUND_ROWS() AS `found_rows`;";
    $rows = mysql_query($sql);
    $rows = mysql_fetch_assoc($rows);
    $total_rows = $rows['found_rows'];
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $employees[] = array(
    'EmployeeID' => $row['EmployeeID'],
    'FirstName' => $row['FirstName'],
    'LastName' => $row['LastName'],
    'Title' => $row['Title'],
    'Address' => $row['Address'],
    'City' => $row['City'],
    'Country' => $row['Country'],
    'Notes' => $row['Notes']
    );
    }
    $data[] = array(
    'TotalRows' => $total_rows,
    'Rows' => $employees
    );
    echo json_encode($data);
    }
    ?>

    i want export ROWS of JSON file to CVS but dont use jqxgrid load .
    How can do it. Thank for help

    Export data from json data #31225

    Peter Stoev
    Keymaster

    Hi nguyentran,

    You can populate the Grid from your JSON and then call the “exportdata” method passing the required parameters. The first parameter should be “csv”. For example about exporting data using jqxGrid, please look at – http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/dataexport.htm?arctic

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Export data from json data #31226

    nguyentran
    Member

    i can do this but i dont want have gridview . i want export direct json

    Export data from json data #31240

    nguyentran
    Member

    can u help me peter? thank u so much

    Export data from json data #31241

    Peter Stoev
    Keymaster

    Hi nguyentran,

    Well, you cannot use the Grid’s Export capabilities without a Grid. If you wish, export the Grid’s data and then remove the Grid from your web page by calling the Grid’s destroy method.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.