Author Topic: When I import data using ajax, I want the PgGrid to refresh  (Read 5184 times)

Jongki, Baek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
When I import data using ajax, I want the PgGrid to refresh
« on: August 24, 2018, 01:20:53 pm »
Hi.

I am looking for answers to two questions.

1) When I import data using ajax, I want the PgGrid to refresh (update).
    * sample source

2) It is Spring-based data that is provided as sample when saved as excel.
    I want a JSP-based source.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #1 on: August 24, 2018, 01:42:03 pm »
1. Please make yourself familiar with ajax request response lifecycle of grid.

https://paramquery.com/pro/tutorial#topic-loaddata

Example of remote request: https://paramquery.com/pro/demos/filter_header

2. JSP source is not available, request and response is independent of any server language / framework.
You need to be familiar with elementary GET/POST requests and JSON serialization / deserialization.

Excel export ( if that's what you need ) can be done in browser itself without round trip to server.

https://paramquery.com/pro/demos/export_local

Jongki, Baek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #2 on: August 24, 2018, 05:04:25 pm »
1) When I import data using ajax, I want the PgGrid to refresh (update).
button click
call  aaa.jsp?type=a     grid display

another button click
call  aaa.jsp?type=b    grid display

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #3 on: August 24, 2018, 05:18:07 pm »
Solution is already mentioned on this page:

https://paramquery.com/pro/tutorial#topic-loaddata

Assign the response from your ajax call to grid and call refreshDataAndView

Code: [Select]
grid.option('dataModel.data', response);
 grid.refreshDataAndView();

Jongki, Baek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #4 on: August 25, 2018, 02:19:11 am »
Thank you for your help.

try, return Message:
The object does not support the 'refreshDataAndView' property or method.

I added a text file
----------------------------------------------------------------------------------

function setData()
{
     var datag1 = [
          [1, 'Exxon Mobil', '339938.0', '36130.0'],
          [2, 'Wal-Mart Stores', '315654.0', '11231.0'],
          [3, 'Royal Dutch Shell', '306731.0', '25311.0'],
          [4, 'BP', '267600.0', '22341.0']
        ];


    $("#grid_array").pqGrid( 'option', 'dataModel.data', datag1 ).refreshDataAndView();   
    //************************************************************************
    //* return Message:
         //* The object does not support the 'refreshDataAndView' property or method.
    //************************************************************************
    
   // grid.option('dataModel.data', datag1 );
   // grid.refreshDataAndView();
}
« Last Edit: August 25, 2018, 02:22:10 am by Jongki, Baek »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #5 on: August 27, 2018, 11:19:11 am »
pqGrid methods can be called in 2 alternative ways: https://paramquery.com/pro/tutorial#topic-methods

refreshDataAndView can't be called on jQuery variable directly, please update it to pqGrid( 'refreshDataAndView ' )

Jongki, Baek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #6 on: August 29, 2018, 07:58:29 pm »
It was solved with your help.

However, another problem occurred.
Some data is missing when exporting Excel.
Please check the data.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #7 on: August 31, 2018, 10:30:03 am »
Could you please share a jsiddle instead of attachments.

Jongki, Baek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: When I import data using ajax, I want the PgGrid to refresh
« Reply #8 on: September 02, 2018, 03:01:55 pm »
Hi.

I attached the file you requested.

But, pqgrid.min.js is file size over. not add.


pqgrid.min.js INFO
/**
 * ParamQuery Pro
 *
 * Copyright (c) 2012-2018 Paramvir Dhindsa (http://paramquery.com)
 * Released under Evaluation license
 * http://paramquery.com/pro/license/evaluate
 *
 */