This topic is locked
[SOLVED]

 set Wheretab to active

4/19/2020 8:52:57 AM
PHPRunner General questions
J
Jack72 author

I created extra tabs on a list page with the WHERE Tabs API (tabs based on records in table), this works perfect.



WhereTabs::DeleteTab($table,"");

$mybutton = "<button type='button' id='tabbutton".$i."' class='btn btn-outline-primary' style='color: black; background-color:".$gdata["Color"]."'>"

.$gdata["Name"]."<span class='badge' style='margin-left: 10px';>".$draftcount."/".$totalcount."</span></button>";



WhereTabs::addTab($table,"TargetGroup='".$gdata["Id"]."'", $mybutton, "grouptab".$i);


The first tab (All data) which is created automatically in design time is deleted.
When you open the page, no tab is active and all data is shown.
Solved that by putting the following in the OnPageLoad event:

var ActiveTABID = $('li[class=active]').find('a[data-tabid]').attr('data-tabid');

if (!ActiveTABID){

$('button[id=tabbutton1]').click();

}



The question: is there a better way to set one of the tabs to 'active', preferrably from URL (without first loading all data and then simulating the 'click' event)?
Thanks

J.

Sergey Kornilov admin 4/20/2020

When you click a certain tab you can see that URL changes, for instance here is the example of the URL where 'Germany' tab is selected.

customers_list.php?tab=germany


So you can add something like this to the List page BeforeProcess event:

if (empty($_GET["tab"])) {

header("Location: customers_list.php?tab=germany");

exit();

}
M
markynewport 4/21/2020

Hi there,
Just saw this topic and was wondering,

For searching when using tabs,

I know that there is a number added to the tab when a result is found,

but I was wondering is there a way to change tab color after search when result is in that tab.

I have been asked this by a few users.

Regards,

Mark.