我试图换掉小组但没有运气。基本上我必须按顺序对它们进行分组:
ROOM3
- Yoga, Martha busy-3
- Bacon, Anna busy-3
.........
...............
ROOM1
- Brady, Marsha busy
- McDonald, Jane busy
...............
....................
ROOM2
- Steve, Ana busy-2
- tester busy-2
.........
...............
简单来说,我想保持这样的分组顺序:
ROOM3 - > ROOM1 - > ROOM2
这是我的工作代码:
答案 0 :(得分:1)
可能有更好的解决方案,但如果您向roomOrderId
对象的每一行添加data
,则可以按此字段进行排序:
sortField="roomOrderId"
修改强>
您可以手动将roomOrderId
添加到每一行:
this.data.forEach(function(row) {
if(row.room==="ROOM1") {
row.roomOrderId = 2;
} else if(row.room==="ROOM2") {
row.roomOrderId = 3;
} else if(row.room==="ROOM3") {
row.roomOrderId = 1;
}
});
查看我的Plunker
答案 1 :(得分:0)
我在数据对象中添加了额外的pos字段:
<p-dataTable [value]="data" sortField="room" rowGroupMode="subheader" groupField="room" expandableRowGroups="true"
[sortableRowGroup]="false" sortField="pos" sortOrder="1">
<ng-template pTemplate="rowgroupheader" let-rowData>{{rowData.room}} - INFO</ng-template>
<p-column field="status" header="ID"></p-column>
<p-column field="name" header="Title"></p-column>
</p-dataTable>
并在html中:
<?php
include 'conn.php';
$result = ("SELECT * FROM usrdata");
$count = mysqli_query($conn, $result);
echo'<table border=1px>'; // opening table tag
echo'<th>id</th><th>email</th><th>Password</th>';
while ($data = mysqli_fetch_array($count)) {
// we are running a while loop to print all the rows in a table
echo'<tr>'; // printing table row
echo '<td>' . $data['id'] . '</td><td>' . $data['email'] . '</td> <td>' . $data['password'] . '</td>';
echo '<td><input type="button" name="delete" value="delete"></td>';
}
echo'</tr>'; // closing table row
echo '</table>';
if ($_GET) {
if (isset($_GET['delete'])) {
delete();
}
}
function delete() {
$delete1 = ("DELETE FROM `usrdata` WHERE id = '$id'");
$result = mysqli_query($conn, $delete1) or die(mysqli_error());
echo "record deleted";
}
?>
将按您给定的顺序排序。