I'm looking for an example of drag & drop columns with react-sortable-hoc and react-virtualized, I have not figured out how I can do it.
Is there anyone who has a solution?
<Table
height={height}
width={1500}
headerHeight={styles.rowHeight}
rowHeight={styles.rowHeight}
rowCount={tableData.length}
rowGetter={getRow}
headerStyle={styles.headerRow}
rowStyle={getRowStyle}
headerClassName="headerColumn"
>
{
columns.map((line, key) => (
<Column
key={key}
width={line.width}
dataKey={line.dataKey}
label={line.label}
/>
))
}
</Table>
I succeeded for the rows but not for columns by following this link: https://embed.plnkr.co/N4iYHYE9gPLp4Y3NHbhk/
Related
To quickly summarize, my first table's rows gets multiplied by the amount of rows in the second table possibly due to my join:
Table 1:(bbr_group) I only have two rows
1
Table 2:(bbr_group_type) I only need to get group_type_name, joined by group_type_id
2
Controller:
public function fetchgroup(){
$all_groups = HmsBbrGroup::join('hms_bbr_group_type', 'hms_bbr_group.group_type_id', '=', 'hms_bbr_group.group_type_id')
->orderBy('group_id', 'ASC')->get();
return response()->json([
'all_groups'=>$all_groups,
]);
}
Table: (with ajax)
success: function (response){
var tbody="";
$.each(response.all_groups, function (key, group) {
tbody+=`
<tr>
<td><p class="font-weight-bold mb-0">${group.group_name}</p>${group.group_description}</td>
<td><p>${group.group_type_name}</p></td>
<td><p>users here</p></td>
<td><p>status here</p></td>
<td>
<button type="button" value="${group.group_id}" class="edit_group btn btn-outline-secondary"><i class="fas fa-edit"></i> Edit</button>
<button type="button" value="${group.group_id}" class="delete_group btn btn-outline-secondary"><i class="fas fa-trash"></i> Delete</button>
</td>
</tr>`;
});
$('#main-group-list tbody').html(tbody)
}
Here is the situation of my output: As you can see even if there are only two rows, it shows the row with every group name from the second table
3
I need to show the table with only the two rows in hms_bbr_group with the left join group_type_name. In this case, both are "General"
I am not sure if the join in the controller or the table is the reason for the duplicates. I'd like some feed back if this line is correct:
$all_groups = HmsBbrGroup::join('hms_bbr_group_type', 'hms_bbr_group.group_type_id', '=', 'hms_bbr_group.group_type_id')
Any help would be great. thank you
Your joining condition is wrong. You are using hms_bbr_group table in both side of equal. I think this would be like following:
$all_groups = HmsBbrGroup::join('hms_bbr_group_type', 'hms_bbr_group.group_type_id', '=', 'hms_bbr_group_type.group_type_id')
->orderBy('group_id', 'ASC')->get();
I have the following dynamic Angular material 6 tables.
<table mat-table [dataSource]="animalDataSource" matSort *ngIf="animal && animal.length > 0">
<ng-container *ngFor="let disCol of animalColumns;" matColumnDef="{{disCol}}">
<th mat-header-cell *matHeaderCellDef mat-sort-header >{{disCol}}</th>
<td mat-cell *matCellDef="let rowValue;">{{rowValue[disCol]}}
<button *ngIf="disCol == 'Action'" mat-mini-fab class="delete-icon" (click)="deleteAnimalData(rowValue)">
<mat-icon>delete</mat-icon>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="animalColumns"></tr>
<tr mat-row *matRowDef="let rowdata; columns: animalColumns;"></tr>
</table>
And here's my script:
this.animals = [];
this.animalColumns = [];
for (var i in animalList) {
this.animal = {
"Id": animalList[i]["_id"],
"Animal": animalList[i].name,
"Created By": animalList[i].createdBy,
"Created On": new Date(animalList[i].dateOfEntry)
}
this.animals.push(this.animal);
}
this.animalDataSource = new MatTableDataSource(this.animals);
for (let displayColName in this.animals[0]) {
this.animalColumns.push(displayColName);
}
this.animalColumns.push("Action");
There are 4 columns in the table. And I don't need the 'Id' column to be displayed in the table. I have tried giving *ngIf and [style.display]='none'. Both are hiding the column with the full-length gap between the columns.
I could have removed the 'Id' field from the object, but I need the value of the 'Id' column when the user clicks on the delete button[method: deleteAnimalData(rowValue)].
Please suggest me, without removing the 'ID' key from the object, how I can hide the column.
The way I was able to make it work is by having an array of objects(say animalObjects) that define all the table columns building the template.
Once they are all defined I have another array that has the name of the columns (animalColumns) to be displayed.
When you need to hide a column then you can remove the item from the 2nd array (animalColumns) while leaving the first (animalObjects) untouched.
You basically have to create the table with all the columns, then update the displaycolumn property with the modified animalColumn array.
stackblitz example here
Just do NOT add the ID to animalColumns, as this array is what defines your columns. See columns: animalColumns in your HTML
My question may be not easy to explain but I am going to do my best.
I have 3 tables :
medicine
patient
patient_medicine
the third table contains 3 columns :
auto increment (id)
medicine_id
patient_id
I make a query that display all data in medicine table and if there is a patient id found in patient_medicine table I check it and those that are not found are not checked.
A- controller
public function showPatientMedicine()
{
$data['patient_id']=$this->input->post('patient_id');
$data['medicine'] = $this->model_admin->medicine();
$this->load->view('admin/show-Patient-Medicine',$data);
}
B- VIEW
<table>
<thead>
<tr>
<th>List</th><th></th>
</tr>
</thead>
<tbody>
<?php
foreach($medicine as $row){
$patient_med=$this->db->select('medicine_id')
->where('patient_id',$patient_id)
->where('medicine_id',$row->id)
->get('patient_medicine')->row('medicine_id');
if($row->id==$patient_med){
$checked="checked";
} else {
$checked="";
}
?>
<tr>
<td>
</td>
<td>
<input type='checkbox' value="<?=$row->id?>" <?=$checked?> />
</td>
</tr>
<?php
}
?>
</tbody>
</table>
THIS QUERY SHOWS ME ALL MEDICINES AND CHECK THE MEDICINES THAT ARE FOUND IN PATIENT_MEDICINE TABLE
MY QUESTION IS :
HOW CAN I SHOW ALL MEDICINES THAT ARE CHECKED IN THE FIRST POSITION OR HOW TO ORDER BY CHECKED CHECKBOX ?
THANK YOU IN ADVANCE.
Try this,
SELECT * FROM `medicine` as a left join (select medicine_id,patient_id from patient_medicine where patient_id = 2) as b on a.id = b.medicine_id
Put the above query in your controller, it will automatically sort the result based on patient id, if patient details found. it will return null for all other details in rows except medicine details.
So you can just
<?php foreach($medicine as $row){ ?>
<input type='checkbox' value="<?=$row->id?>" <?php echo !is_null($row->patient_id)?'checked':''; ?> />
<?php } ?>
I have a table with few thousand records on few pages in a simple html table.. I made a search function that works fine apart from one thing... It displays only one result in a table (which is great cause it means it works!).But... I was wondering is there a way to display back the table with all records, with the one that i was searching for in the middle and highlighted? Here's a simplified table that I have :
<table class="nogap" cellpadding="1" bgcolor="#00000" cellspacing="1" style="margin:110px 0 0 5px; width:100%; border-color:#B6D6F6;" >
<tbody>
<?php include 'dbconn.php';?>
$con = mysqli_connect($host,$user,$pass,$db) or (header( 'Location: errorpage.php' ));
if (mysqli_connect_errno($con)) { header( 'Location: errorpage.php' ); }
$sql = "SELECT * FROM $tb1 ORDER BY (Serial_num +1) LIMIT $offset, $rowsperpage";
$result = mysqli_query($con, $sql) or (header( 'Location: errorpage.php' ));
$row = mysqli_num_rows($result);
while ($row = $result->fetch_assoc())
{
$product = $row['Prod_type'].$row['Serial_num'];
<tr id="mstrTable" class="lovelyrow">
<td width="5%"><?php echo $product;?></td>
<td width="5%"><?php echo $row['Customer'];?></td>
<td width="7%">
<a href="#"
onmouseover="ajax_showTooltip(window.event,'getptn.php?prd=<?php echo $p;?>',this);return false"
onmouseout="ajax_hideTooltip()">
<?php echo$row['Prod_info'];?>
</a>
</td>
</tr>
}
</table>
Thanks!
First of all don't give the same html id attribute to each row (mstrTable). Html Ids should be unique per page.
Instead mark table rows with unique ids, eg:
$html .= "<td id='row_".$row['id']."'>"
Then do a search query first, remember item id, figure out what page should be queried, query the whole page, attach classess 'greyedout' and 'highlighted' to rows accordingly and then you might try this javascript function to scroll down to the item:
https://developer.mozilla.org/en-US/docs/Web/API/element.scrollIntoView
i have a questions about managament rows in grid. For example we have food/cost table like:
Fruit | cost
------------
Apple | 10$
Bannan| 5$
We can create form like:
<form>
<input type='text' name='Fruits[0][fruit] value='Apple' /> <input type='text' name='Fruits[0][cost] value='10$' /> <br>
<input type='text' name='Fruits[1][fruit] value='Bannan' /> <input type='text' name='Fruits[1][cost] value='5$' />
</form>
And save all it like:
if ($is_new)
if(isset($_POST['Fruits'])) {
foreach ($_POST['Fruits'] as $fruit) {
$model = new Fruit();
$model->attributes = $fruit;
$model->save();
}
}
} else { //here code for update, $model->load()... }
All fine, we can update both rows... But that if i want add new? All fine method above make all good, but what if i delete 1 row? In my base i will have 2 rows, but i need only 1.
Here 2 ways i see:
1. Delete all fruits from databse on every update when POST count != databse count
2. We can load database rows, write loop, check every row... but its so hard, so many code...
How you manage new and deleted rows?
Use Yii data handlers to print results, like 'CGridView' :
http://www.yiiframework.com/doc/api/1.1/CGridView/