7.3 Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 04:14:10 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 CELL edit with Add, Delete and Export buttons https://phpgrid.com/example/cell-edit-with-add-new-and-delete-buttons/ Tue, 21 May 2019 22:55:07 +0000 http://phpgrid.com/?p=9524 phpGrid has a less known edit feature called “CELL”. It’s similar to INLINE edit, but with only a single editable cell when selected. This is not a fully-fledged feature from jqGrid itself, especially it missed add and delete out of the box. However, we have hacked (but works) Javascript to included the add and delete […]

The post CELL edit with Add, Delete and Export buttons appeared first on phpGrid - PHP Datagrid.

]]>
phpGrid has a less known edit feature called “CELL”. It’s similar to INLINE edit, but with only a single editable cell when selected. This is not a fully-fledged feature from jqGrid itself, especially it missed add and delete out of the box. However, we have hacked (but works) Javascript to included the add and delete functions through custom javascript.

Pay close attention to the “url” property. Be sure it points to a valid edit.php address.

1
2
3
4
5
6
7
8
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  


$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg->enable_edit('CELL');
$dg -> display();

ADD & DELETE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$(function() {
   
    $('#addNew').on('click', function(){
        $("#orders").jqGrid('editGridRow', "new", {url:'/phpGrid/edit.php?dt=json&gn=orders&oper=add'} );
    });

    $('#delRow').on('click', function(){
        var selRowId = $("#orders").jqGrid('getGridParam', 'selrow');
        $.ajax({
                url: '/phpGrid/edit.php?dt=json&gn=orders',
                data: {'id': selRowId, 'oper': 'del'},
                type: 'POST',
                dataType: 'JSON'
        });
        $('#orders').trigger( 'reloadGrid' );
    });
})
<button id="addNew">Add New</button>
<button id="delRow">Delete Selected</button>

See Live Example!


EXPORT (new)

To add Export buttons to the bottom toolbar, insert the following BEFORE $dg->$display(); Be sure to replace /phpGrid/ with the actual phpGrid absolute file path on your web server

1
2
3
4
5
6
7
8
9
10
11
12
$exportDropdown =<<< EXPORTDROPDOWN
$('#orders_pager1_left').append (`<div style=padding-right: 16px;>Export:
    <select onchange="document.location.href=this.options[this.selectedIndex].value;">
        <option>---</option>
        <option value='/phpGridx/export.php?gn=orders&export_type=excel'>Excel</option>
        <option value='/phpGridx/export.php?gn=orders&export_type=pdf'>PDF</option>
        <option value='/phpGridx/export.php?gn=orders&export_type=html'>HTML</option>
        <option value='/phpGridx/export.php?gn=orders&export_type=csv'>CSV</option>
        <option value='/phpGridx/export.php?gn=orders&export_type=excelxml'>ExcelXML</option>
    </select></div>`);
EXPORTDROPDOWN
;
$dg->before_script_end = $exportDropdown;

The post CELL edit with Add, Delete and Export buttons appeared first on phpGrid - PHP Datagrid.

]]>
9524
Bootstrap Grid Layout https://phpgrid.com/example/bootstrap-grid-layout/ Tue, 02 Apr 2019 22:09:23 +0000 http://phpgrid.com/?p=9519

The datagrid can also be displayed and positioned easily in a Bootstrap Grid System layout, uses a series of containers, rows, and columns to the layout that is fully responsive. 12345678910111213141516<div class="container"> <div class="row"> <div class="col-md-4">.col-md-4</div> <div class="col-md-4">.col-md-4 <?php use phpCtrl\C_DataGrid; require_once("/file/path/to/conf.php");   $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); $dg -> set_theme('bootstrap'); […]

The post Bootstrap Grid Layout appeared first on phpGrid - PHP Datagrid.

]]>

The datagrid can also be displayed and positioned easily in a Bootstrap Grid System layout, uses a series of containers, rows, and columns to the layout that is fully responsive.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div class="container">
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4
<?php
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg -> set_theme('bootstrap');
$dg -> display();
?>
</div>
<div class="col-md-4">.col-md-4</div>
</div>
</div>

See Live Example!

The post Bootstrap Grid Layout appeared first on phpGrid - PHP Datagrid.

]]>
9519