Skip to content

Instantly share code, notes, and snippets.

@gridphp
Last active June 14, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gridphp/915d2e0834354913fdfd338d47d50a53 to your computer and use it in GitHub Desktop.
Save gridphp/915d2e0834354913fdfd338d47d50a53 to your computer and use it in GitHub Desktop.
Demo: Loading image for all Ajax calls - https://www.gridphp.com
<?php
/**
* PHP Grid Component
*
* @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
* @version 1.5.2
* @license: see license.txt included in package
*/
// include db config
include_once("../../config.php");
// include and create obje<?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
*/
/**
* Basic Grid Sample
* You can use inline edit mode or dialog edit mode
*/
include_once("../../config.php");
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);
$opt["caption"] = "Sample Grid";
$g->set_options($opt);
$g->table = "clients";
$g->set_columns($cols,true);
$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>
<script src="https://gitcdn.xyz/repo/malsup/blockui/master/jquery.blockUI.js" type="text/javascript"></script>
</head>
<body>
<div>
<?php echo $out?>
</div>
<script>
$(document).ajaxStart(function() {
$.blockUI({
css: {width: '100px'},
message: '<img src="https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif">',
});
})
$(document).ajaxComplete(function() {
$.unblockUI();
});
$(document).ajaxError(function() {
$.unblockUI();
});
</script>
</body>
</html>
@mrabd423
Copy link

This code is not showing any thing when i add some record in the grid.

@mrabd423
Copy link

Loader is not showing on the right time. I've added a record and i've setup some logics in the on_insert , Loader is not showing when i just click on the submit , loader.gif shows when it come to complete.
Please resolve this issue. Just like you can see the image below. I've clicked on the submit button and it is now yello. But not showing the loader.
image

@gridphp
Copy link
Author

gridphp commented Sep 7, 2017

I've updated demo to fix above issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment