⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

put the action buttons in first column



Jefer

Jefer
  • profile picture
  • Member

Posted 30 July 2013 - 15:18 PM

I've been using Grocery Crud for about 5 months and I am very happy with it. However, I need to know if it is possible to put the action buttons (edit, delete buttons) in the table's first column. I am using flexigrid theme.

 

Thanks in advance.


kenshicu

kenshicu
  • profile picture
  • Member

Posted 30 July 2013 - 15:35 PM

edit the file list.php
it found in: "\assets\grocery_crud\themes\flexigrid\views\list.php"

 

in the code, swap the first block of php code, with the second:

		<thead>
			<tr class='hDiv'>
			    //this block
				<?php foreach($columns as $column){?>
				<th width='<?php echo $column_width?>%'>
					<div class="text-left field-sorting <?php if(isset($order_by[0]) &&  $column->field_name == $order_by[0]){?><?php echo $order_by[1]?><?php }?>" 
						rel='<?php echo $column->field_name?>'>
						<?php echo $column->display_as?>
					</div>
				</th>
				<?php }?>
				//with this
				<?php if(!$unset_delete || !$unset_edit || !empty($actions)){?>
				<th align="left" abbr="tools" axis="col1" class="" width='20%'>
					<div class="text-right">
						<?php echo $this->l('list_actions'); ?>
					</div>
				</th>
				<?php }?>
			</tr>
		</thead>

then swap the php code block, which begins thus: <?php foreach($columns as $column){?>

 

with the following php code block that starts well: <?php if(!$unset_delete || !$unset_edit || !empty($actions)){?>   


Jefer

Jefer
  • profile picture
  • Member

Posted 30 July 2013 - 17:05 PM

@kenshicu You are right, but that change is only for thead. I also had to change the following code to the bottom for the tbody.

 

Thanks!!!

<?php foreach($columns as $column){?>
			<td width='<?php echo $column_width?>%' class='<?php if(isset($order_by[0]) &&  $column->field_name == $order_by[0]){?>sorted<?php }?>'>
				<div class='text-left'><?php echo $row->{$column->field_name} != '' ? $row->{$column->field_name} : '&nbsp;' ; ?></div>
			</td>
			<?php }?>

kenshicu

kenshicu
  • profile picture
  • Member

Posted 01 August 2013 - 16:10 PM

good, but I said at the end:

 

then swap the php code block, which begins thus: <?php foreach($columns as $column){?>

with the following php code block that starts well: <?php if(!$unset_delete || !$unset_edit || !empty($actions)){?>

 

Put another way, (besides change the thead):

 

is, change this:

<?php foreach($list as $num_row => $row){ ?>        
	<tr  <?php if($num_row % 2 == 1){?>class="erow"<?php }?>>
	   <?php foreach($columns as $column){?>
              ...
	    <?php }?>
	    <?php if(!$unset_delete || !$unset_edit || !empty($actions)){?>
              ...
	    <?php }?>
	</tr>
<?php } ?>  

for this:

<?php foreach($list as $num_row => $row){ ?>        
	<tr  <?php if($num_row % 2 == 1){?>class="erow"<?php }?>>
	    <?php if(!$unset_delete || !$unset_edit || !empty($actions)){?>
              ...
	    <?php }?>
	    <?php foreach($columns as $column){?>
              ...
	    <?php }?>
	</tr>
<?php } ?>