How to set TV at the same row which ID was edited in DV?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
fbrano
Veteran Member
Posts: 63
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

How to set TV at the same row which ID was edited in DV?

Post by fbrano » 2021-01-27 08:59

How to set TV at the same row which ID was edited in DV?
BF - AppGini Pro V 5.94 rev.1132 Great!
Plugins: Mass Update + Search Page Maker + Summary Reports + Udemy Course
Partizanske, SK

User avatar
fbrano
Veteran Member
Posts: 63
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: How to set TV at the same row which ID was edited in DV?

Post by fbrano » 2021-01-27 09:50

After close Detail View of the some ID how to set active the row with the same ID at the Table View.
BF - AppGini Pro V 5.94 rev.1132 Great!
Plugins: Mass Update + Search Page Maker + Summary Reports + Udemy Course
Partizanske, SK

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1050
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to set TV at the same row which ID was edited in DV?

Post by jsetzer » 2021-01-27 10:12

That looks very complicated at the first glance.

Depending on the user's individual filters, his/her permissions, on configured or custom sorting and on the number of records per page (pagination) that specific record may be on a different page than page #1 (pagination) or even not visible at all.

In case it is on a different page or not available at all, I'm afraid there is no hooks-only solution.

In case that record is on the first page, the procedure could be the following (which requires additional coding and knowledge of PHP and Javascript):
  1. in _dv hook, store $selectedID (if set) into $_SESSION
  2. in TABLENAME_header with $contentType == 'tableview' fetch the ID from $_SESSION, append a Javascript to $header which stores the ID in a javascript variable, remove the ID from $_SESSION
  3. in TABLENAME-tv.js, after load, get the ID stored before, then try to find a tr[data-id='YOUR-ID']
  4. If you can find it, highlight the row as you like, for example by using "active" class on the tr.
As mentioned before: This requires some advanced knowledge in PHP, session-handling and Javascript. I guess this will take some time to implement - depending on your skills.
Kind regards,
<js />

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1249
Joined: 2018-04-01 10:12

Re: How to set TV at the same row which ID was edited in DV?

Post by pböttcher » 2021-01-27 21:11

Hi,

not sure if it needs to be that complicated. You can try to add this to your hooks/TABLENAME.php -> tablename_header function.

Code: Select all

			case 'tableview':
				if ($_REQUEST['SelectedID']) { 
				$header='<%%HEADER%%><script>
					$j(function() {b='.$_REQUEST["SelectedID"].';eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp(\'\\\\b\'+c+\'\\\\b\',\'g\'),k[c])}}return p}(\'1=0(\\\'13[12-11="\\\'+10+\\\'"]\\\');0("9,8").7({6:1.5().4-0(".3").2()})\',10,14,\'$j|a|height|navbar|top|offset|scrollTop|animate|body|html|b|id|data|tr\'.split(\'|\')))});
				</script>';
				}
				break;

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1050
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to set TV at the same row which ID was edited in DV?

Post by jsetzer » 2021-01-28 08:37

Wow, I'm impressed @pböttcher!

Your smart code works fine when opening a record from Table View which should be the case for most AppGini Users.

Very little backdraw:
When opening the record from a custom page, from a custom navbar menu item, by clicking a permalink or by code (redirect from PHP or Javascript) and returning to TV it only works if that record is on the first page of pagination. Otherwise your script cannot find that row (because it is not in the first page).

Thanks a lot for sharing!
Kind regards,
<js />

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1249
Joined: 2018-04-01 10:12

Re: How to set TV at the same row which ID was edited in DV?

Post by pböttcher » 2021-01-28 19:37

Hi Jan,

true, but that was not the my understanding of the question, as for custom settings, of course the standard AppGini function will not work as usual any more.
But for the standard behaviour, open TV, click in record, get DV opened and close DV, jump back to this record in the TV it should work.

User avatar
fbrano
Veteran Member
Posts: 63
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: How to set TV at the same row which ID was edited in DV?

Post by fbrano » 2021-01-30 01:37

I do not see any changes in behaviour of TV after going back from editing record in DV.
BF - AppGini Pro V 5.94 rev.1132 Great!
Plugins: Mass Update + Search Page Maker + Summary Reports + Udemy Course
Partizanske, SK

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1249
Joined: 2018-04-01 10:12

Re: How to set TV at the same row which ID was edited in DV?

Post by pböttcher » 2021-01-30 09:42

Can you post where you added the code?
Are you using the standard AppGini TV, or a customized one?
How many items do you have in your TV?

Post Reply