Search multiple datepicker on same grid
Posted
by
DHF
on Stack Overflow
See other posts from Stack Overflow
or by DHF
Published on 2012-12-05T08:06:56Z
Indexed on
2012/12/05
11:05 UTC
Read the original article
Hit count: 469
I'm using multiple datepicker on same grid and I face the problem to get a proper result.
I used 3 datepicker in 1 grid.
Only the first datepicker (Order Date)is able to output proper result while the other 2 datepicker (Start Date & End Date) are not able to generate proper result.
There is no problem with the query, so could you find out what's going on here?
Thanks in advance!
php wrapper
<?php
ob_start();
require_once 'config.php';
// include the jqGrid Class
require_once "php/jqGrid.php";
// include the PDO driver class
require_once "php/jqGridPdo.php";
// include the datepicker
require_once "php/jqCalendar.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = "SELECT c.CompanyID, c.CompanyCode, c.CompanyName, c.Area, o.OrderCode, o.Date, m.maID ,m.System, m.Status, m.StartDate, m.EndDate, m.Type FROM company c, orders o, maintenance_agreement m WHERE c.CompanyID = o.CompanyID AND o.OrderID = m.OrderID ";
// Set the table to where you update the data
$grid->table = 'maintenance_agreement';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setPrimaryKeyId('maID');
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grouping_ma_details.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
"sortable"=>true,
"rownumbers"=>true,
"caption"=>"Group by Maintenance Agreement",
"rowNum"=>20,
"height"=>'auto',
"width"=>1300,
"sortname"=>"maID",
"hoverrows"=>true,
"rowList"=>array(10,20,50),
"footerrow"=>false,
"userDataOnFooter"=>false,
"grouping"=>true,
"groupingView"=>array(
"groupField" => array('CompanyName'),
"groupColumnShow" => array(true), //show or hide area column
"groupText" =>array('<b> Company Name: {0}</b>',),
"groupDataSorted" => true,
"groupSummary" => array(true)
)
));
if(isset($_SESSION['login_admin']))
{
$grid->addCol(array(
"name"=>"Action",
"formatter"=>"actions",
"editable"=>false,
"sortable"=>false,
"resizable"=>false,
"fixed"=>true,
"width"=>60,
"formatoptions"=>array("keys"=>true),
"search"=>false
), "first");
}
// Change some property of the field(s)
$grid->setColProperty("CompanyID", array("label"=>"ID","hidden"=>true,"width"=>30,"editable"=>false,"editoptions"=>array("readonly"=>"readonly")));
$grid->setColProperty("CompanyName", array("label"=>"Company Name","hidden"=>true,"editable"=>false,"width"=>150,"align"=>"center","fixed"=>true));
$grid->setColProperty("CompanyCode", array("label"=>"Company Code","hidden"=>true,"width"=>50,"align"=>"center"));
$grid->setColProperty("OrderCode", array("label"=>"Order Code","width"=>110,"editable"=>false,"align"=>"center","fixed"=>true));
$grid->setColProperty("maID", array("hidden"=>true));
$grid->setColProperty("System", array("width"=>150,"fixed"=>true,"align"=>"center"));
$grid->setColProperty("Type", array("width"=>280,"fixed"=>true));
$grid->setColProperty("Status", array("width"=>70,"align"=>"center","edittype"=>"select","editoptions"=>array("value"=>"Yes:Yes;No:No"),"fixed"=>true));
$grid->setSelect('System', "SELECT DISTINCT System, System AS System FROM master_ma_system ORDER BY System", false, true, true, array(""=>"All"));
$grid->setSelect('Type', "SELECT DISTINCT Type, Type AS Type FROM master_ma_type ORDER BY Type", false, true, true, array(""=>"All"));
$grid->setColProperty("StartDate", array("label"=>"Start Date","width"=>120,"align"=>"center","fixed"=>true,
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d M Y")
));
// this is only in this case since the orderdate is set as date time
$grid->setUserTime("d M Y");
$grid->setUserDate("d M Y");
$grid->setDatepicker("StartDate",array("buttonOnly"=>false));
$grid->datearray = array('StartDate');
$grid->setColProperty("EndDate", array("label"=>"End Date","width"=>120,"align"=>"center","fixed"=>true,
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d M Y")
));
// this is only in this case since the orderdate is set as date time
$grid->setUserTime("d M Y");
$grid->setUserDate("d M Y");
$grid->setDatepicker("EndDate",array("buttonOnly"=>false));
$grid->datearray = array('EndDate');
$grid->setColProperty("Date", array("label"=>"Order Date","width"=>100,"editable"=>false,"align"=>"center","fixed"=>true,
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d M Y")
));
// this is only in this case since the orderdate is set as date time
$grid->setUserTime("d M Y");
$grid->setUserDate("d M Y");
$grid->setDatepicker("Date",array("buttonOnly"=>false));
$grid->datearray = array('Date');
// This command is executed after edit
$maID = jqGridUtils::GetParam('maID');
$Status = jqGridUtils::GetParam('Status');
$StartDate = jqGridUtils::GetParam('StartDate');
$EndDate = jqGridUtils::GetParam('EndDate');
$Type = jqGridUtils::GetParam('Type');
// This command is executed immediatley after edit occur.
$grid->setAfterCrudAction('edit', "UPDATE maintenance_agreement SET m.Status=?,
m.StartDate=?,
m.EndDate=?,
m.Type=?
WHERE m.maID=?",
array($Status,$StartDate,$EndDate,$Type,$maID));
$selectorder = <<<ORDER
function(rowid, selected)
{
if(rowid != null) {
jQuery("#detail").jqGrid('setGridParam',{postData:{CompanyID:rowid}});
jQuery("#detail").trigger("reloadGrid");
// Enable CRUD buttons in navigator when a row is selected
jQuery("#add_detail").removeClass("ui-state-disabled");
jQuery("#edit_detail").removeClass("ui-state-disabled");
jQuery("#del_detail").removeClass("ui-state-disabled");
}
}
ORDER;
// We should clear the grid data on second grid on sorting, paging, etc.
$cleargrid = <<<CLEAR
function(rowid, selected)
{
// clear the grid data and footer data
jQuery("#detail").jqGrid('clearGridData',true);
// Disable CRUD buttons in navigator when a row is not selected
jQuery("#add_detail").addClass("ui-state-disabled");
jQuery("#edit_detail").addClass("ui-state-disabled");
jQuery("#del_detail").addClass("ui-state-disabled");
}
CLEAR;
$grid->setGridEvent('onSelectRow', $selectorder);
$grid->setGridEvent('onSortCol', $cleargrid);
$grid->setGridEvent('onPaging', $cleargrid);
$grid->setColProperty("Area", array("width"=>100,"hidden"=>false,"editable"=>false,"fixed"=>true));
$grid->setColProperty("HeadCount", array("label"=>"Head Count","align"=>"center", "width"=>100,"hidden"=>false,"fixed"=>true));
$grid->setSelect('Area', "SELECT DISTINCT AreaName, AreaName AS Area FROM master_area ORDER BY AreaName", false, true, true, array(""=>"All"));
$grid->setSelect('CompanyName', "SELECT DISTINCT CompanyName, CompanyName AS CompanyName FROM company ORDER BY CompanyName", false, true, true, array(""=>"All"));
$custom = <<<CUSTOM
jQuery("#getselected").click(function(){
var selr = jQuery('#grid').jqGrid('getGridParam','selrow');
if(selr)
{
window.open('http://www.smartouch-cdms.com/order.php?CompanyID='+selr);
}
else alert("No selected row");
return false;
});
CUSTOM;
$grid->setJSCode($custom);
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true,"searchOnEnter"=>false,"defaultSearch"=>"cn"));
// Enable navigator
$grid->navigator = true;
// disable the delete operation programatically for that table
$grid->del = false;
// we need to write some custom code when we are in delete mode.
// get the grid operation parameter to see if we are in delete mode
// jqGrid sends the "oper" parameter to identify the needed action
$deloper = $_POST['oper'];
// det the company id
$cid = $_POST['CompanyID'];
// if the operation is del and the companyid is set
if($deloper == 'del' && isset($cid) )
{
// the two tables are linked via CompanyID, so let try to delete the records in both tables
try {
jqGridDB::beginTransaction($conn);
$comp = jqGridDB::prepare($conn, "DELETE FROM company WHERE CompanyID= ?", array($cid));
$cont = jqGridDB::prepare($conn,"DELETE FROM contact WHERE CompanyID = ?", array($cid));
jqGridDB::execute($comp);
jqGridDB::execute($cont);
jqGridDB::commit($conn);
} catch(Exception $e) {
jqGridDB::rollBack($conn);
echo $e->getMessage();
}
}
// Enable only deleting
if(isset($_SESSION['login_admin']))
{
$grid->setNavOptions('navigator', array("pdf"=>true, "excel"=>true,"add"=>false,"edit"=>true,"del"=>false,"view"=>true, "search"=>true));
}
else
$grid->setNavOptions('navigator', array("pdf"=>true, "excel"=>true,"add"=>false,"edit"=>false,"del"=>false,"view"=>true, "search"=>true));
// In order to enable the more complex search we should set multipleGroup option
// Also we need show query roo
$grid->setNavOptions('search', array(
"multipleGroup"=>false,
"showQuery"=>true
));
// Set different filename
$grid->exportfile = 'Company.xls';
// Close the dialog after editing
$grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Update Company","bSubmit"=>"Update","dataheight"=>"auto"));
$grid->setNavOptions('add',array("closeAfterAdd"=>true,"addCaption"=>"Add New Company","bSubmit"=>"Update","dataheight"=>"auto"));
$grid->setNavOptions('view',array("Caption"=>"View Company","dataheight"=>"auto","width"=>"1100"));
ob_end_clean(); //solve TCPDF error
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
javascript code
jQuery(document).ready(function ($) {
jQuery('#grid').jqGrid({
"width": 1300,
"hoverrows": true,
"viewrecords": true,
"jsonReader": {
"repeatitems": false,
"subgrid": { "repeatitems": false }
},
"xmlReader": {
"repeatitems": false,
"subgrid": { "repeatitems": false }
},
"gridview": true,
"url": "session_ma_details.php",
"editurl": "session_ma_details.php",
"cellurl": "session_ma_details.php",
"sortable": true,
"rownumbers": true,
"caption": "Group by Maintenance Agreement",
"rowNum": 20,
"height": "auto",
"sortname": "maID",
"rowList": [10, 20, 50],
"footerrow": false,
"userDataOnFooter": false,
"grouping": true,
"groupingView": {
"groupField": ["CompanyName"],
"groupColumnShow": [false],
"groupText": ["<b> Company Name: {0}</b>"],
"groupDataSorted": true,
"groupSummary": [true]
}, "onSelectRow": function (rowid, selected) {
if (rowid != null) {
jQuery("#detail").jqGrid('setGridParam', { postData: { CompanyID: rowid } });
jQuery("#detail").trigger("reloadGrid");
// Enable CRUD buttons in navigator when a row is selected
jQuery("#add_detail").removeClass("ui-state-disabled");
jQuery("#edit_detail").removeClass("ui-state-disabled");
jQuery("#del_detail").removeClass("ui-state-disabled");
}
}, "onSortCol": function (rowid, selected) {
// clear the grid data and footer data
jQuery("#detail").jqGrid('clearGridData', true);
// Disable CRUD buttons in navigator when a row is not selected
jQuery("#add_detail").addClass("ui-state-disabled");
jQuery("#edit_detail").addClass("ui-state-disabled");
jQuery("#del_detail").addClass("ui-state-disabled");
}, "onPaging": function (rowid, selected) {
// clear the grid data and footer data
jQuery("#detail").jqGrid('clearGridData', true);
// Disable CRUD buttons in navigator when a row is not selected
jQuery("#add_detail").addClass("ui-state-disabled");
jQuery("#edit_detail").addClass("ui-state-disabled");
jQuery("#del_detail").addClass("ui-state-disabled");
},
"datatype": "json",
"colModel": [
{
"name": "Action", "formatter": "actions", "editable": false, "sortable": false, "resizable": false,
"fixed": true, "width": 60, "formatoptions": { "keys": true }, "search": false
},
{
"name": "CompanyID", "index": "CompanyID", "sorttype": "int", "label": "ID", "hidden": true, "width": 30,
"editable": false, "editoptions": { "readonly": "readonly" }
},
{
"name": "CompanyCode", "index": "CompanyCode", "sorttype": "string", "label": "Company Code",
"hidden": true, "width": 50, "align": "center", "editable": true
},
{
"name": "CompanyName", "index": "CompanyName", "sorttype": "string", "label": "Company Name", "hidden": true,
"editable": false, "width": 150, "align": "center", "fixed": true, "edittype": "select",
"editoptions": {
"value": "Aquatex Industries:Aquatex Industries;Benithem Sdn Bhd:Benithem Sdn Bhd;Daily Bakery Sdn Bhd:Daily Bakery Sdn Bhd;Eurocor Asia Sdn Bhd:Eurocor Asia Sdn Bhd;Evergrown Technology:Evergrown Technology;Goldpar Precision:Goldpar Precision;MicroSun Technologies Asia:MicroSun Technologies Asia;NCI Industries Sdn Bhd:NCI Industries Sdn Bhd;PHHP Marketing:PHHP Marketing;Smart Touch Technology:Smart Touch Technology;THOSCO Treatech:THOSCO Treatech;YHL Trading (Johor) Sdn Bhd:YHL Trading (Johor) Sdn Bhd;Zenxin Agri-Organic Food:Zenxin Agri-Organic Food",
"separator": ":",
"delimiter": ";"
}, "stype": "select",
"searchoptions": {
"value": ":All;Aquatex Industries:Aquatex Industries;Benithem Sdn Bhd:Benithem Sdn Bhd;Daily Bakery Sdn Bhd:Daily Bakery Sdn Bhd;Eurocor Asia Sdn Bhd:Eurocor Asia Sdn Bhd;Evergrown Technology:Evergrown Technology;Goldpar Precision:Goldpar Precision;MicroSun Technologies Asia:MicroSun Technologies Asia;NCI Industries Sdn Bhd:NCI Industries Sdn Bhd;PHHP Marketing:PHHP Marketing;Smart Touch Technology:Smart Touch Technology;THOSCO Treatech:THOSCO Treatech;YHL Trading (Johor) Sdn Bhd:YHL Trading (Johor) Sdn Bhd;Zenxin Agri-Organic Food:Zenxin Agri-Organic Food",
"separator": ":",
"delimiter": ";"
}
},
{
"name": "Area", "index": "Area", "sorttype": "string", "width": 100, "hidden": true, "editable": false,
"fixed": true, "edittype": "select",
"editoptions": {
"value": "Cemerlang:Cemerlang;Danga Bay:Danga Bay;Kulai:Kulai;Larkin:Larkin;Masai:Masai;Nusa Cemerlang:Nusa Cemerlang;Nusajaya:Nusajaya;Pasir Gudang:Pasir Gudang;Pekan Nenas:Pekan Nenas;Permas Jaya:Permas Jaya;Pontian:Pontian;Pulai:Pulai;Senai:Senai;Skudai:Skudai;Taman Gaya:Taman Gaya;Taman Johor Jaya:Taman Johor Jaya;Taman Molek:Taman Molek;Taman Pelangi:Taman Pelangi;Taman Sentosa:Taman Sentosa;Tebrau 4:Tebrau 4;Ulu Tiram:Ulu Tiram",
"separator": ":",
"delimiter": ";"
},
"stype": "select",
"searchoptions": {
"value": ":All;Cemerlang:Cemerlang;Danga Bay:Danga Bay;Kulai:Kulai;Larkin:Larkin;Masai:Masai;Nusa Cemerlang:Nusa Cemerlang;Nusajaya:Nusajaya;Pasir Gudang:Pasir Gudang;Pekan Nenas:Pekan Nenas;Permas Jaya:Permas Jaya;Pontian:Pontian;Pulai:Pulai;Senai:Senai;Skudai:Skudai;Taman Gaya:Taman Gaya;Taman Johor Jaya:Taman Johor Jaya;Taman Molek:Taman Molek;Taman Pelangi:Taman Pelangi;Taman Sentosa:Taman Sentosa;Tebrau 4:Tebrau 4;Ulu Tiram:Ulu Tiram",
"separator": ":",
"delimiter": ";"
}
},
{
"name": "OrderCode", "index": "OrderCode", "sorttype": "string", "label": "Order No.", "width": 110,
"editable": false, "align": "center", "fixed": true
},
{
"name": "Date", "index": "Date", "sorttype": "date", "label": "Order Date", "width": 100,
"editable": false, "align": "center", "fixed": true,
"formatter": "date", "formatoptions": { "srcformat": "Y-m-d H:i:s", "newformat": "d M Y" },
"editoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
}, "searchoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
}
},
{ "name": "maID", "index": "maID", "sorttype": "int", "key": true, "hidden": true, "editable": true },
{
"name": "System", "index": "System", "sorttype": "string", "width": 150, "fixed": true, "align": "center",
"edittype": "select",
"editoptions": {
"value": "Payroll:Payroll;TMS:TMS;TMS & Payroll:TMS & Payroll",
"separator": ":",
"delimiter": ";"
},
"stype": "select",
"searchoptions": {
"value": ":All;Payroll:Payroll;TMS:TMS;TMS & Payroll:TMS & Payroll",
"separator": ":",
"delimiter": ";"
}, "editable": true
},
{
"name": "Status", "index": "Status", "sorttype": "string", "width": 70, "align": "center",
"edittype": "select", "editoptions": { "value": "Yes:Yes;No:No" }, "fixed": true, "editable": true
},
{
"name": "StartDate", "index": "StartDate", "sorttype": "date", "label": "Start Date",
"width": 120, "align": "center", "fixed": true,
"formatter": "date", "formatoptions": { "srcformat": "Y-m-d H:i:s", "newformat": "d M Y" },
"editoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
},
"searchoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
}, "editable": true
},
{
"name": "EndDate", "index": "EndDate", "sorttype": "date", "label": "End Date", "width": 120,
"align": "center", "fixed": true,
"formatter": "date", "formatoptions": { "srcformat": "Y-m-d H:i:s", "newformat": "d M Y" },
"editoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
}, "searchoptions": {
"dataInit": function(el) {
setTimeout(function() {
if (jQuery.ui) {
if (jQuery.ui.datepicker) {
jQuery(el).datepicker({ "disabled": false, "dateFormat": "dd M yy" });
jQuery('.ui-datepicker').css({ 'font-size': '75%' });
}
}
}, 100);
}
}, "editable": true
},
{
"name": "Type", "index": "Type", "sorttype": "string", "width": 530, "fixed": true, "edittype": "select",
"editoptions": {
"value": "Comprehensive MA:Comprehensive MA;FOC service, 20% spare part discount:FOC service, 20% spare part discount;Standard Package, FOC 1 time service, 20% spare part discount:Standard Package, FOC 1 time service, 20% spare part discount;Standard Package, FOC 2 time service, 20% spare part discount:Standard Package, FOC 2 time service, 20% spare part discount;Standard Package, FOC 3 time service, 20% spare part discount:Standard Package, FOC 3 time service, 20% spare part discount;Standard Package, FOC 4 time service, 20% spare part discount:Standard Package, FOC 4 time service, 20% spare part discount;Standard Package, FOC 6 time service, 20% spare part discount:Standard Package, FOC 6 time service, 20% spare part discount;Standard Package, no free:Standard Package, no free",
"separator": ":",
"delimiter": ";"
},
"stype": "select",
"searchoptions": {
"value": ":All;Comprehensive MA:Comprehensive MA;FOC service, 20% spare part discount:FOC service, 20% spare part discount;Standard Package, FOC 1 time service, 20% spare part discount:Standard Package, FOC 1 time service, 20% spare part discount;Standard Package, FOC 2 time service, 20% spare part discount:Standard Package, FOC 2 time service, 20% spare part discount;Standard Package, FOC 3 time service, 20% spare part discount:Standard Package, FOC 3 time service, 20% spare part discount;Standard Package, FOC 4 time service, 20% spare part discount:Standard Package, FOC 4 time service, 20% spare part discount;Standard Package, FOC 6 time service, 20% spare part discount:Standard Package, FOC 6 time service, 20% spare part discount;Standard Package, no free:Standard Package, no free",
"separator": ":",
"delimiter": ";"
},
"editable": true
}
],
"postData": { "oper": "grid" },
"prmNames": { "page": "page", "rows": "rows", "sort": "sidx", "order": "sord", "search": "_search", "nd": "nd", "id": "maID", "filter": "filters", "searchField": "searchField", "searchOper": "searchOper", "searchString": "searchString", "oper": "oper", "query": "grid", "addoper": "add", "editoper": "edit", "deloper": "del", "excel": "excel", "subgrid": "subgrid", "totalrows": "totalrows", "autocomplete": "autocmpl" },
"loadError": function(xhr, status, err) {
try {
jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,
'<div class="ui-state-error">' + xhr.responseText + '</div>',
jQuery.jgrid.edit.bClose,
{ buttonalign: 'right' }
);
} catch(e) {
alert(xhr.responseText);
}
},
"pager": "#pager"
});
jQuery('#grid').jqGrid('navGrid', '#pager',
{ "edit": true, "add": false, "del": false, "search": true, "refresh": true, "view": true, "excel": true, "pdf": true, "csv": false, "columns": false },
{ "drag": true, "resize": true, "closeOnEscape": true, "dataheight": "auto", "errorTextFormat": function (r) { return r.responseText; }, "closeAfterEdit": true, "editCaption": "Update Company", "bSubmit": "Update" },
{ "drag": true, "resize": true, "closeOnEscape": true, "dataheight": "auto", "errorTextFormat": function (r) { return r.responseText; }, "closeAfterAdd": true, "addCaption": "Add New Company", "bSubmit": "Update" },
{ "errorTextFormat": function (r) { return r.responseText; } }, { "drag": true, "closeAfterSearch": true, "multipleSearch": true },
{ "drag": true, "resize": true, "closeOnEscape": true, "dataheight": "auto", "Caption": "View Company", "width": "1100" }
);
jQuery('#grid').jqGrid('navButtonAdd', '#pager', {
id: 'pager_excel', caption: '', title: 'Export To Excel', onClickButton: function (e) {
try {
jQuery("#grid").jqGrid('excelExport', { tag: 'excel', url: 'session_ma_details.php' });
} catch (e) {
window.location = 'session_ma_details.php?oper=excel';
}
}, buttonicon: 'ui-icon-newwin'
});
jQuery('#grid').jqGrid('navButtonAdd', '#pager', {
id: 'pager_pdf',
caption: '',
title: 'Export To Pdf',
onClickButton: function (e) {
try {
jQuery("#grid").jqGrid('excelExport', { tag: 'pdf', url: 'session_ma_details.php' });
} catch (e) {
window.location = 'session_ma_details.php?oper=pdf';
}
},
buttonicon: 'ui-icon-print'
});
jQuery('#grid').jqGrid('filterToolbar', { "stringResult": true, "searchOnEnter": false, "defaultSearch": "cn" });
jQuery("#getselected").click(function () {
var selr = jQuery('#grid').jqGrid('getGridParam', 'selrow');
if (selr) {
window.open('http://www.smartouch-cdms.com/order.php?CompanyID=' + selr);
}
else alert("No selected row");
return false;
});
});
© Stack Overflow or respective owner