Hi,
Can we update subfile grid using Ajax call?
We are trying to add a search button which will search on client side first and based on certain conditions, will make Ajax call to get more records from database. Can Ajax handler update the subfile grid with new results, do we have any option to do this?
If we have a EJS table, can we use this to update new results from Ajax call?
Subfile and Ajax
-
- New User
- Posts: 11
- Joined: Fri Jan 20, 2017 1:48 pm
- First Name: Kishan
- Last Name: Aindala
- Company Name: Dealertrack
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Subfile and Ajax
How are you loading the grid?
If you are using the "data url" (which makes an AJAX call to load the grid) then you shouldn't have any problems here.
Where this will be tricky is if you are using RPG file operations (or Cobol or equivalent) to load the grid. In this case, the grid data is stored in two places -- both in the browser and on the server. The server side stuff is what the RPG program has created by writing/updating records, and then this is sent to the browser. Since AJAX only updates the browser part of things, this can be problematic. Basically, you'll be okay if you only make "updates" but do not add/remove rows.
If you are doing that type of grid (loading from RPG/Cobol/etc) it might be easier and will definitely be more robust if you just submit control back to the rPG program to make changes instead of trying to do it from AJAX.
For the EJS stuff... I'm not as familiar with that. But, I believe we automatically call the EJS JavaScript routines when loading an html container that has an EJS template coded into it. We do that when a screen is rendered... and the variables we supply to the EJS routines are the data that we got from the screen data sent by IBM i. So this built-in support for running EJS would be very limited from AJAX. See what I mean? If it's run when the screen is rendered using data from the screen, how would your AJAX possibly affect it? On the other hand, you could certainly call the EJS routines yourself instead of letting us do it for you -- in that case, you can do whatever you want.
If you are using the "data url" (which makes an AJAX call to load the grid) then you shouldn't have any problems here.
Where this will be tricky is if you are using RPG file operations (or Cobol or equivalent) to load the grid. In this case, the grid data is stored in two places -- both in the browser and on the server. The server side stuff is what the RPG program has created by writing/updating records, and then this is sent to the browser. Since AJAX only updates the browser part of things, this can be problematic. Basically, you'll be okay if you only make "updates" but do not add/remove rows.
If you are doing that type of grid (loading from RPG/Cobol/etc) it might be easier and will definitely be more robust if you just submit control back to the rPG program to make changes instead of trying to do it from AJAX.
For the EJS stuff... I'm not as familiar with that. But, I believe we automatically call the EJS JavaScript routines when loading an html container that has an EJS template coded into it. We do that when a screen is rendered... and the variables we supply to the EJS routines are the data that we got from the screen data sent by IBM i. So this built-in support for running EJS would be very limited from AJAX. See what I mean? If it's run when the screen is rendered using data from the screen, how would your AJAX possibly affect it? On the other hand, you could certainly call the EJS routines yourself instead of letting us do it for you -- in that case, you can do whatever you want.
Who is online
Users browsing this forum: No registered users and 6 guests