Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test pgp
<?php
/**
* PHP Grid Component
*
* @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
* @version 2.0.0
* @license: see license.txt included in package
*/
/**
* todos:Grid with 2 column layout, implemented tabindex for vertical tab focusing
* and custom width & height of dialog boxes
*/
// include db config
include_once("../../config.php");
// include and create object
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
// Database config file to be passed in phpgrid constructor
$db_conf = array(
"type" => PHPGRID_DBTYPE,
"server" => PHPGRID_DBHOST,
"user" => PHPGRID_DBUSER,
"password" => PHPGRID_DBPASS,
"database" => PHPGRID_DBNAME
);
$g = new jqgrid($db_conf);
// set few params
$opt["caption"] = "Sample Grid";
$opt["edit_options"]["beforeSubmit"] = "function(){ if (show_dialog()==true) return [true,'']; else return [false,'No se han guardado los datos:<br>El usuario cancelo la acccion']; }"; $opt["beforeSaveRow"] = "function(){ if (confirm('Seguro que desea guardar los datos?')==true) return [true,'']; else return [false,'Se ha cancelado el guardadoNo se han guardado los datos:<br>El usuario cancelo la acccion']; }";
$g->set_options($opt);
// set database table for CRUD operations
$g->table = "clients";
$col = array();
$col["title"] = "Id"; // caption of column
$col["name"] = "client_id";
$col["width"] = "20";
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Name"; // caption of column
$col["name"] = "name";
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Gender"; // caption of column
$col["name"] = "gender";
$col["width"] = "30";
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Company"; // caption of column
$col["name"] = "company";
$col["editable"] = true;
$cols[] = $col;
$g->set_columns($cols);
$g->set_actions(array(
"add"=>true, // allow/disallow add
"edit"=>true, // allow/disallow edit
"delete"=>true, // allow/disallow delete
"view"=>true, // allow/disallow view
"rowactions"=>true, // show/hide row wise edit/del/save option
)
);
// render grid
$out = $g->render("list1");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
<script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
</head>
<body>
<?php /* css for add/edit dialog editing */ ?>
<div style="margin:10px">
<?php echo $out?>
</div>
<button onclick='show_dialog()'>Custom Dialog</button>
<div id="dialog-confirm" style="display:none; width:500px; height: 500px;" title="Did you clicked it?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:4px;"></span>
¿Seguro de guardar los datos?.
</p>
</div>
<script>
function show_dialog()
{
$("#dialog-confirm" ).dialog({
resizable: false,
width: 500,
modal: true,
create: function (event, ui) {
$(event.target).parent().css('z-index', 20000);
},
buttons: {
"Confirmar": function() {
alert('Yes clicked');
$( this ).dialog( "close" );
return true;
},
"Cancelar": function() {
$( this ).dialog( "close" );
return false;
}
}
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.