Open diamante123 opened 9 years ago
I like this one tho, would be great!
Hi @diamante123!
If I understand correctly, the table is not sorting? I'm not sure what is meant by this statement:
"JO" is then moved to the "reservierungen" tab, but it doesn't disappear from the "device" tab unless I hit refresh.
Everything in the device tab should be hidden when the tab switches.
Anyway, to get tablesorter to work it needs to be initialized since the table didn't exist until after the ajax call. Try something like this:
$(function() {
$( "#tabs" ).tabs({
activate: function( event, ui ) {
ui.newPanel.find("#domainsTable").tablesorter({
/* tablesorter options */
});
}
});
});
If that doesn't work, please share the HTML of the two tables.
Thanks for your reply. No, the table is sorting, that works great.
Everything in the device tab should be hidden when the tab switches.
That works as well. Only thing that doesn't work:
When I hit the button next to an entry in the device table, "for example: "JO"", I want the entry to vanish from the device table right after I clicked the button, kinda like I deleted the entry.
Currently the entry only vanishes when I hit refresh OR change the tab.
I hope you get me now, haha
NOTE: When I hit the button, I get:
Uncaught TypeError: undefined is not a function it refers to my index.php line:41 which is my "reservieren" function
What does the "reservieren" function look like? Are you using a delegated event binding?
if I'm understanding this right it sounds like he just needs to add a removeRow in the button function.
Oh sry, I meant "reserve" function, which looks like this:
function reserve(id) {
$.ajax({
type: "GET",
url: "reserve.php?geraeteID=" + id,
cache: false,
complete: function (data) {
$("#tabs").tabs('load', 0);
}
});
}
Never heard of delegated events, and due to my bad English it's really hard to understand that site =/
What code are you using to hide the "JO" row?
After hitting the button, the "reserve.php" is called and the status of the device is set to "RESERVED" and the userID of a currently logged-in user is stored in a mysql database.
My "geraete.php" shows all devices which are not "RESERVED". I am getting so desperate right now, I am willing to donate to your blog if you can help me :+1:
I assume you are calling it via ajax, can I see that ajax call please you are just missing a removeRow() in the complete part of it. Also for the record I feel @Mottie deserves a donation either way ;)
because you are using ajax to update the row in the db, but the tables do not know to reload the data you have 2 choices, use remove and add Row() from one table to the other, or refresh the data in the table using ajax after the db is updated.
I do this stuff all the time since I'm the php guy here ;) I'm also on IRC to help.
It might be easier to help if you jumped on the #tablesorter
irc channel on freenode.net
The refresh-data-method sounds great, I hope I can find out how to do that. Since I'm at work and I go home now, I will enter the IRC channel tomorrow and really looking forward to find a solution to my problem :) Thank you both
Damn computer @ work won't let me connect to the IRC channel... Hope you guys are willing to help me here. I wonder why this does not reload my TABS:
complete: function (data) {
$("#tabs").tabs('load', 0);
}
Maybe you need my geraete.php as well...
<html><head>
<link rel="stylesheet" href="jquery-ui-1.11.4/jquery-ui.css">
<script src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="./table/js/jquery-latest.js"></script>
<script type="text/javascript" src="./table/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="./table/js/jquery.tablesorter.widgets.js"></script>
<script type="text/javascript">
$(function() {
$("#domainsTable").tablesorter({
theme: 'metro-dark',
// hidden filter input/selects will resize the columns, so try to minimize the change
widthFixed : true,
// initialize zebra striping and filter widgets
widgets: ["zebra", "filter", "uitheme"],
widgetOptions : {
// jQuery selector string of an element used to reset the filters
filter_reset : 'button.reset',
// add custom selector elements to the filter row
filter_formatter : {
2 : function(){
}
}
}
});
})
</script>
</head>
<body>
<?php
require_once ('config.php');
$db_link = mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
mysqli_set_charset($db_link, 'utf8');
$sql = "SELECT deviceID, deviceName, categoryName "
. "FROM (device LEFT JOIN category ON devoce.categoryID=category.categoryID) WHERE deleted != 1 AND status = 'AVAILABLE'";
$db_erg = mysqli_query($db_link, $sql);
if (!$db_erg) {
die('Invalid Request: ' . mysqli_error($db_link));
}
?>
<table border="5" id="domainsTable" class="tablesorter">
<thead>
<tr>
<th></th>
<th class="first-name filter-select" data-placeholder="Choose name">Name</th>
<th class="first-name filter-select" data-placeholder="Choose category">Category</th>
</tr>
</thead>
<?php
echo '<tbody>';
while ($row = mysqli_fetch_array($db_erg, MYSQL_ASSOC)) {
echo "<tr>";
$id = $row['deviceID'];
echo '<td>';
echo '<button onclick="reservieren(' . $id . ');">Reservieren</button>';
echo '</td>';
echo "<td>" . $zeile['deviceName'] . "</td>";
echo "<td>" . $zeile['kategorieName'] . "</td>";
echo '</tr>';
}
echo '</tbody>';
echo "</table>";
mysqli_free_result($db_erg);
?>
Hi, I know there were people having similar problems that I do, but none of the solutions worked for me. I hope you'll understand my English:
I have two JqueryUI tabs which show two different tables with TableSorter. That works great. The tabs are called "devices (here:geräte (german))" and "reservations(reservierungen)". When I hit the "reservieren" button on the first tab, the device tab, I want the entry in the table to vanish and appear in the "reservations" table. In the reservations table, the user should be able to end the reservations by clicking on a button. The buttons both work, but I always have to reload the page, and that's really not what I want.
It used to work, but when I added TableSorter, it stopped working...
Parts of my index.php:
The tabs:
Again, when I click on the "reservieren" button at the first entry, "JO" is then moved to the "reservierungen" tab, but it doesn't disappear from the "device" tab unless I hit refresh.
Hope somebody gets my issue :D Thanks in advance!