Reputation: 18178
I have started using the free-jqGrid available here: https://github.com/free-jqgrid. I have it working with an old server script that return XML data. I was using an older version of jqGrid before, and I consider moving to this new free-jqGrid version an upgrade.
The problem I am having is in the filter toolbar.
$("#jqGrid").jqGrid('filterToolbar');
When I fill in the filter toolbar and press ENTER, the server request is made successfully and the filtered data looks like it loads correctly... BUT then the word I just entered in the toolbar is wiped clean. Previously the word or phrase would stay there, which is the desired action.
I was wondering if there is an option to leave the search phrase in there, or do I need to return a special value from the server?
Thanks!
Here is the web code:
<script src="/jqGrid/js/jquery-1.11.0.min.js"></script>
<script src="/CSS/blue_and_yellow/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="CSS/blue_and_yellow/jquery-ui.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.13.2/css/ui.jqgrid.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.13.2/js/jquery.jqgrid.min.js"></script>
<h1>Shipping History</h1>
<button id="back_to_shipping_menu">Back to Shipping Menu</button>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
<style type="text/css">
.ui-jqgrid-btable {
font-size: 14px;
}
</style>
<script type="text/javascript">
jQuery(function($){
$('#back_to_shipping_menu').button().click(function(){
window.location.href = "/index.php/operations/production/shipping"
});
var lastSel;
$("#jqGrid").jqGrid({
url:'/phpAJAX/Master/master_grid_v1.php',
postData:{
'arg1':'new_shipping_history'
},
height: 'auto',
shrinkToFit: true,
width: Math.floor($(window).width()*.78),
datatype: 'xml',
mtype: 'POST',
colNames:[
'row_id',
'Ship Date',
'Insert/Label',
'JobNum',
'Qnty Shipped',
'Ship_Type',
'Carrier',
'Time',
'Status',
'Confirm',
'Date Confirm',
'Customer'
],
colModel:[
{width:20,name:'row_id',hidden:true},
{width:20,name:'ship_date'},
{width:13,name:'insert_label'},
{width:13,name:'jobnum'},
{width:17,name:'Qnty_Shipped', formatter:'number', formatoptions: {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, defaultValue: "0"}},
{width:20,name:'Ship_Type', edittype:'select'},
{width:25,name:'Carrier', edittype:'select'},
{width:20,name:'Time', edittype:'select'},
{width:20,name:'Status', edittype:'select'},
{width:10,name:'Ship_Confirm'},
{width:20,name:'ship_ts', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'm/d/Y'}},
{width:20,name:'Customer'}
],
sortname: 'ship_ts',
sortorder: 'desc',
viewrecords: true,
gridview: true,
caption: 'Shipping History',
rowNum: 20,
rowList:[20,50,100],
pager: '#jqGridPager'
});
$("#jqGrid").jqGrid('navGrid', '#jqGridPager', {edit:false,add:false, del: false, search: false, refresh:true});
$("#jqGrid").jqGrid('filterToolbar');
})
</script>
Upvotes: 0
Views: 940
Reputation: 221997
Thank you for the bug report! The problem: I implemented in free jqGrid restoring the filter toolbar based on the current filter. The feature works only in case of stringResult: true
mode, when jqGrid send all information about the filter inside of one filters
parameter (see here), like in case of usage advanced searching (multipleSearch: true
).
The usage of the new feature with legacy searching following to cleaning the filter toolbar. It's the bug, which I fixed (see the commit) in the current code of free jqGrid. If you need to use version 4.13.2 then you can add loadFilterDefaults: false
option which will remove restoring the filter:
$("#jqGrid").jqGrid('filterToolbar', { loadFilterDefaults: false });
Upvotes: 2