SID-02141: using edittable within jqtabpane
| Status: |
Answered |
TWiki version: |
|
Perl version: |
|
| Category: |
JQueryPlugin |
Server OS: |
CentOS 5.2 |
Last update: |
6 years ago |
I have setup tabs on my topic using jqtabpane jqtab. Within my tabs I have tables which I have made to be editable by using edittable.
The problem I'm having, is that when you click on the edit button of the table in any tab that is not the first tab, the page refreshes and returns to the first tab. If you navigate back to your tab, the table is ready to edit.
My question: Is it possible, that after a user clicks on edit to edit a table in the 3rd tab, that after the page refreshes it returns to that 3rd tab?
Sample of my code below between jqtab variables:
%TABLE{ sort="off" tablerules="all" tableborder="1" cellpadding="4" cellspacing="3" cellborder="1" headerrows="1"}%
%EDITTABLE{ format="| select, 1, Select Branch, %FORMFIELD{"OPS Branch Code"}%, %FORMFIELD{"Sat OPS Branch Code"}%, %FORMFIELD{"Sat2 OPS Branch Code"}%, %FORMFIELD{"Sat3 OPS Branch Code"}% | text, 50 | label, 0, %USERNAME% | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" editbutton="Click here to enter comment"}%
| *Branch Location* | *Comment* | *User* | *Date & Time Entered* |
--
Christopher Crowe - 2015-12-31
Discussion and Answer
That is a bit tricky. Fortunately, the TABPANE offers a
select="" parameter to control the active tab, and the EDITTABLE emits a hidden
ettablenr URL parameter in POST on edit. You can tie that together with a CALCULATE.
Test JQTABPANE and EDITTABLE in Tab 2:
TABPANE with CALCULATE formula:
%JQTABPANE{ select="%CALCULATE{$IF($EXACT(%URLPARAM{ettablenr}%, 1), 2, 1)}%" }%
- test for URL parameter
ettablenr,
- if
1 (e.g. first EDITTABLE), select tab 2,
- else select tab 1
Details in
JQueryPlugin,
VarJQTABPANE,
VarURLPARAM,
VarCALCULATE
--
Peter Thoeny - 2016-01-02
Hi Peter,
Happy New Years and thanks for answering this.
This is definitely going in the right direction but not quite working. When I enter the select=" " parameter it seems to work the reverse from your example. When I edit a table in tab 1, it refreshed and returns to tab 2. When I edit a table in tab 2, it refreshes and returns to tab 1. I can change the "... 1), 2, 1)" around to get it to work right, but that tells me something may not be working correctly. I had to change it to "... 2), 2, 1)"
How to get it working for all tabs? I have 9 Tabs, each with an EDITTABLE that I would need to have returned to the tab in which the edit button was clicked. I tried to add more to the $IF statement, but any changes I made seem to break the page.
--
Christopher Crowe - 2016-01-04
If you have a predictable sequence of tabs and edit tables you simply feed the proper
ettablenr to the
select. Untested:
select="%CALCULATE{$MAX(1, %URLPARAM{ettablenr}%)}%"
--
Peter Thoeny - 2016-01-05
That worked perfect!
--*Example Return to correct tab after using EDITABLE "Edit"*
--
Christopher Crowe - 2016-01-05
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.