<?php 
define("PHPGRID_DBTYPE","Mysql"); // or mysqli
define("PHPGRID_DBHOST","localhost");
define("PHPGRID_DBUSER","mdsoftwareco_rns");
define("PHPGRID_DBPASS","w&S8zzGMx]QI");
define("PHPGRID_DBNAME","mdsoftwareco_rns");

// Automatically make db connection inside lib
define("PHPGRID_AUTOCONNECT",0);

// Basepath for lib
define("PHPGRID_LIBPATH",dirname(__FILE__).DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR);

// set up DB 
//mysql_connect('localhost','mdsoftwareco_rns','w&S8zzGMx]QI');
//mysql_select_db(PHPGRID_DBNAME); 

$link = @mysql_connect('localhost','mdsoftwareco_rns','w&S8zzGMx]QI') or die('Unable to establish a DB     connection');

mysql_select_db('mdsoftwareco_rns',$link);


// include and create object 
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
// you can customize  

$col = array(); 

$col["title"] = "Id"; // caption of column 		class	name	fname	mno	detail

$col["name"] = "id";  

$col["width"] = "10"; 

$cols[] = $col;   

 

 $col = array(); 

$col["title"] = "University Roll Number"; 

$col["name"] = "efn"; 

$col["width"] = "25"; 

$col["editable"] = true; 

$col["search"] = true; // this column is not searchable 

$col["editrules"] = array("required"=>true); // and is required 

$cols[] = $col; 



$col = array(); 

$col["title"] = "College Roll Number"; 

$col["name"] = "croll"; 

$col["width"] = "25"; 

$col["editable"] = true; 

$col["search"] = true; // this column is not searchable 

$col["editrules"] = array("required"=>true); // and is required 
$col["link"] = "http://print_from.php?user_name={croll}"; // e.g. http://domain.com?id={id} given that, there is a column with $col["name"] = "id" exist 

$col["linkoptions"] = "target='_blank'"; // extra params with <a> tag 

$cols[] = $col; 



$col = array(); 

$col["title"] = "Submission date"; 

$col["name"] = "rdate"; 

$col["width"] = "25"; 

$col["editable"] = false; 

$col["search"] = true; // this column is not searchable 

$col["editrules"] = array("required"=>false); // and is required 

$cols[] = $col; 

$g = new jqgrid();

// $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI 

$grid["rowNum"] = 10; // by default 20 

$grid["sortname"] = 'id'; // by default sort grid by this field 

$grid["sortorder"] = "desc"; // ASC or DESC 

$grid["caption"] = "Student Verification"; // caption of grid 

$grid["autowidth"] = true; // expand grid to screen width 

$grid["multiselect"] = true; // allow you to multi-select through checkboxes 

$grid["reloadedit"] = true; // auto reload after editing 

$grid["footerrow"] = true; // Show footer row 

$grid["userDataOnFooter"] = true; // Fill footer row with userdata (with on_data_display event) 



$grid["grouping"] = false; //  

$grid["groupingView"] = array(); 

$grid["groupingView"]["groupField"] = array("rdate"); // specify column name to group listing 

$grid["groupingView"]["groupColumnShow"] = array(true); // either show grouped column in list or not (default: true) 

$grid["groupingView"]["groupText"] = array("<b>{0} - {1} Item(s)</b>"); // {0} is grouped value, {1} is count in group 

$grid["groupingView"]["groupOrder"] = array("desc"); // show group in asc or desc order 

$grid["groupingView"]["groupDataSorted"] = array(true); // show sorted data within group 

$grid["groupingView"]["groupSummary"] = array(false); // work with summaryType, summaryTpl, see column: $col["name"] = "total"; 

$grid["groupingView"]["groupCollapse"] = false; // Turn true to show group collapse (default: false)  

$grid["groupingView"]["showSummaryOnHide"] = false; // show summary row even if group collapsed (hide)  



$g->set_options($grid); 

 $export_type=$_GET['export_type'];

if(export_type=='csv'){

$grid["export"] = array("format"=>"csv", "filename"=>"my-file","range"=>"filtered"); 

}elseif((export_type=='xls')){

$grid["export"] = array("format"=>"xls", "filename"=>"my-file", "heading"=>"Export to Excel Test", "range" => "filtered");

}



 $grid["export"]["range"] = "filtered"; // or "all"

$g->set_options($grid); 



$g->set_actions(array(     

                      "add"=>true, // allow/disallow add 

                        "edit"=>true, // allow/disallow edit 

                        "delete"=>true, // allow/disallow delete 

                        "rowactions"=>true, // show/hide row wise edit/del/save option 

                       "export_excel"=>true, // export excel button 

                         "export_pdf"=>true, // export pdf button 

						

                        "autofilter" => true, // show/hide autofilter for search 

						 "showhidecolumns"=>true, // show/hide row wise edit/del/save option 

                        "search" => "advance" // show single/multi field search condition (e.g. simple or advance) 

                    )  

                ); 



// you can provide custom SQL query to display data 											

$g->select_command = "SELECT id, efn , croll,rdate FROM exam_veri"; 



// this db table will be used for add,edit,delete 

$g->table = "exam_veri"; 



// pass the cooked columns to grid 

$g->set_columns($cols); 



// generate footer data for grand sum 

$e["on_data_display"] = array("filter_display", null, false); 

$g->set_events($e); 



function filter_display($data) 

{ 

    // grand sum total and show in footer user data 

    $add_fees = 0; 

	$Bank_fees = 0;

    foreach($data["params"] as $d) 

    { 

        $add_fees += $d["add_fees"];

		$Bank_fees += $d["Bank_fees"];

} 



    $data["params"]["userdata"] = array("note"=>"Grand Summary","add_fees"=>"Add.: ".$add_fees,"Bank_fees"=>"BnkC: ".$Bank_fees); 

} 



$grid_id = "list1"; 

// generate grid output, with unique grid name as 'list1' 

$out = $g->render($grid_id); 

?> 

<!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> 

    <style> 

    /* change color of group text */ 

    .jqgroup b { 

        color: navy; 

    } 

    </style> 

    <div style="margin:10px"> 

    
     

    <script> 

    jQuery(window).load(function() 

    { 

        // show dropdown in toolbar 

        //jQuery('#list1_pager_left').append('<div style="padding-left: 5px; padding-top:2px; float:left"><select class="chngroup"><option value="clear" >--Select Group By--</option><?php foreach($cols as $c) { if($c["title"] !='Action'){?><option value="<?php echo $c["name"] ?>"><?php echo $c["title"] ?></option><?php }} ?><option value="clear" onChange="frz()">Clear</option> </select></div>'); 



        jQuery(".chngroup").change(function() 

        { 

            var vl = jQuery(this).val();  

            if(vl)  

            {  

                if(vl == "clear")  

                    jQuery("#<?php echo $grid_id ?>").jqGrid('groupingRemove',true);  

                else  

                    jQuery("#<?php echo $grid_id ?>").jqGrid('groupingGroupBy',vl);  

            }  

        }); 

    }); 

    </script>             

    <br> 

    <br> 

    <?php echo $out?> 

    </div>     

</body> 

</html> 

