Hi Will, I’ve tried various versions including adding multikey/multibox per your suggestion. I’ve done so with and without the code I included in my initial post above. But the behavior for selecting rows is not what I expected. If I strip out my code and use your suggested parameters, it doesn’t allow for continuous row selection.
What I really want is the same row selection behavior as what occurs with Google Mail and/or Yahoo Mail: Choosing a group of continuous rows combined with random non continuous rows.
Both Gmail and Yahoo mail allow me to:
Select rows 4 through 9 (click the first box row 4 without shift, then click the 9th row check box with Shift resulting in 6 rows selected.
Then, and in addition to row 4 to 9, select individual rows 12 and then row 19 (checkbox click, no shift key).
Total rows selected: 8
Does jqgrid 5.1 support this, or are there any resources you can point me at that can provide this behavior? I’m using jquery with bootstrap.
Actually, no, I wasn’t aware you require code examples to answer a known issues question.
Is there a private channel I can provide you with login credentials?
Thanks for update on icons. I’m making progress and I have a few more fixes to make based on your input. Very helpful. Thx
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
<!DOCTYPE html> <html lang="en"> <head> <!-- The jQuery library is a prerequisite for all jqSuite products --> <!-- <script src="js/jquery-2.1.1.js"></script> --> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js" type="text/javascript"></script> <script src="js/plugins/jquery-ui/jquery-ui.min.js"></script> <!-- We support more than 40 localizations --> <script src="js/plugins/jqGrid/i18n/grid.locale-en.js"></script> <!-- This is the Javascript file of jqGrid --> <script src="js/plugins/jqGrid/jquery.jqGrid.min.js"></script> <!-- This is the localization file of the grid controlling messages, labels, etc. <!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <!-- The link to the CSS that the grid needs --> <link href="css/plugins/jqGrid/ui.jqgrid-bootstrap-ui.css" rel="stylesheet"> <script> $.jgrid.defaults.width = 780; $.jgrid.defaults.responsive = true; $.jgrid.defaults.styleUI = 'Bootstrap'; </script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <meta charset="utf-8" /> <title>jqGrid Loading Data - Column Reordering</title> </head> <body> <style type="text/css"> /* set the size of the datepicker search control for Order Date*/ #ui-datepicker-div { font-size:11px; } /* set the size of the autocomplete search control*/ .ui-menu-item { } .ui-autocomplete { font-size: 11px; } </style> <table id="jqGrid"></table> <div id="jqGridPager"></div> <script type="text/javascript"> $(document).ready(function () { var filter; $("#jqGrid").jqGrid({ url: 'data.json', mtype: "GET", datatype: "json", colModel: [ { label : "Order ID", //sorttype: 'integer', name: 'OrderID', key: true, width: 75 , colmenu : true, coloptions : {sorting:true, columns: true, filtering: true, seraching:true, grouping:false, freeze : true}, searchoptions : { searchOperMenu : false, sopt : ['eq','gt','lt','ge','le'] } }, { label: "Customer ID", name: 'CustomerID', width: 150, hidedlg : true, // stype defines the search type control - in this case HTML select (dropdownlist) stype: "select", // searchoptions value - name values pairs for the dropdown - they will appear as options searchoptions: { value: " :[All];ALFKI:ALFKI;ANATR:ANATR;ANTON:ANTON;AROUT:AROUT;BERGS:BERGS;BLAUS:BLAUS;BLONP:BLONP;BOLID:BOLID;BONAP:BONAP;BOTTM:BOTTM;BSBEV:BSBEV;CACTU:CACTU;CENTC:CENTC;CHOPS:CHOPS;COMMI:COMMI;CONSH:CONSH;DRACD:DRACD;DUMON:DUMON;EASTC:EASTC;ERNSH:ERNSH;FAMIA:FAMIA;FOLIG:FOLIG;FOLKO:FOLKO;FRANK:FRANK;FRANR:FRANR;FRANS:FRANS;FURIB:FURIB;GALED:GALED;GODOS:GODOS;GOURL:GOURL;GREAL:GREAL;GROSR:GROSR;HANAR:HANAR;HILAA:HILAA;HUNGC:HUNGC;HUNGO:HUNGO;ISLAT:ISLAT;KOENE:KOENE;LACOR:LACOR;LAMAI:LAMAI;LAUGB:LAUGB;LAZYK:LAZYK;LEHMS:LEHMS;LETSS:LETSS;LILAS:LILAS;LINOD:LINOD;LONEP:LONEP;MAGAA:MAGAA;MAISD:MAISD;MEREP:MEREP;MORGK:MORGK;NORTS:NORTS;OCEAN:OCEAN;OLDWO:OLDWO;OTTIK:OTTIK;PERIC:PERIC;PICCO:PICCO;PRINI:PRINI;QUEDE:QUEDE;QUEEN:QUEEN;QUICK:QUICK;RANCH:RANCH;RATTC:RATTC;REGGC:REGGC;RICAR:RICAR;RICSU:RICSU;ROMEY:ROMEY;SANTG:SANTG;SAVEA:SAVEA;SEVES:SEVES;SIMOB:SIMOB;SPECD:SPECD;SPLIR:SPLIR;SUPRD:SUPRD;THEBI:THEBI;THECR:THECR;TOMSP:TOMSP;TORTU:TORTU;TRADH:TRADH;TRAIH:TRAIH;VAFFE:VAFFE;VICTE:VICTE;VINET:VINET;WANDK:WANDK;WARTH:WARTH;WELLI:WELLI;WHITC:WHITC;WILMK:WILMK;WOLZA:WOLZA" } }, { label: "Order Date", name: 'OrderDate', width: 150, sorttype:'date', formatter: 'date', srcformat: 'Y-m-d', stype : 'text', newformat: 'n/j/Y', searchoptions: { // dataInit is the client-side event that fires upon initializing the toolbar search field for a column // use it to place a third party control to customize the toolbar dataInit: function (element) { $(element).datepicker({ id: 'orderDate_datePicker', dateFormat: 'm/d/yy', //minDate: new Date(2010, 0, 1), maxDate: new Date(2020, 0, 1), showOn: 'focus' }); } } }, { label : "Ship Name", name: 'ShipName', width: 150, searchoptions: { // dataInit is the client-side event that fires upon initializing the toolbar search field for a column // use it to place a third party control to customize the toolbar dataInit: function (element) { $(element).autocomplete({ id: 'AutoComplete', source: function(request, response){ this.xhr = $.ajax({ url: 'http://trirand.com/blog/phpjqgrid/examples/jsonp/autocompletep.php?callback=?&acelem=ShipName', data: request, dataType: "jsonp", success: function( data ) { response( data ); }, error: function(model, response, options) { response([]); } }); }, autoFocus: true }); }, sopt : ['cn'] } }, { label: "Freight", sorttype: 'number', name: 'Freight', width: 150, sopt : ['eq'] }, ], loadonce: true, viewrecords: true, width: 780, height: 250, rowNum: 10, colMenu : true, shrinkToFit : true, pager: "#jqGridPager" }); // activate the toolbar searching $('#jqGrid').jqGrid('filterToolbar',{ stringResult: true, //searchOnEnter: false, searchOperators : true }); $('#jqGrid').jqGrid('navGrid',"#jqGridPager", { search: false, // show search button on the toolbar add: false, edit: false, del: false, refresh: true }); $("#save").click(function(){ filter = $("#jqGrid").jqGrid('getGridParam', 'postData').filters; var perm = [ 1, 0, 2, 4, 3 ]; $("#jqGrid").jqGrid('remapColumns', perm, true, false); console.log($("#jqGrid").jqGrid('getGridParam','colModel')); }); $("#load").click(function(){ console.log(filter); $("#jqGrid").jqGrid('refreshFilterToolbar', { filters : filter, onClearVal: function ( elem, name) { if(name === 'CustomerID') { console.log(elem); elem.multiselect('refresh'); } }, onSetVal: function ( elem, name) { if(name === 'CustomerID') { console.log(elem); elem.multiselect('refresh'); } } }); }); var timer; $("#search_cells").on("keyup", function() { var self = this; if(timer) { clearTimeout(timer); } timer = setTimeout(function(){ //timer = null; $("#jqGrid").jqGrid('filterInput', self.value); },0); }); }); </script> </body> </html> |
Thanks for your responses.
For questions 3, 5, and 6, I’ve created a screen shot here:
NEW question, this might be related to the above:
Your example link was helpful. I recreated it locally and I get similar formatting issues as above. Screen shot of formatting issues:
https://app.box.com/s/4jfrk4leh3yccoagzkljwfa1zju3omox" />
I used jqgrid 5.1 . I copied your example code then I changed the paths for the css and js, for my local drive, but it is similar to your original example.
It feels like I’m missing a link to css or js?
Here’s my code:
[code]
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;!– The jQuery library is a prerequisite for all jqSuite products –&amp;gt;
&amp;lt;!– &amp;lt;script src="js/jquery-2.1.1.js"&amp;gt;&amp;lt;/script&amp;gt; –&amp;gt;
&amp;lt;script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="js/plugins/jquery-ui/jquery-ui.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;!– We support more than 40 localizations –&amp;gt;
&amp;lt;script src="js/plugins/jqGrid/i18n/grid.locale-en.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;!– This is the Javascript file of jqGrid –&amp;gt;
&amp;lt;script src="js/plugins/jqGrid/jquery.jqGrid.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;!– This is the localization file of the grid controlling messages, labels, etc.
&amp;lt;!– A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom –&amp;gt;
&amp;lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"&amp;gt;
&amp;lt;!– The link to the CSS that the grid needs –&amp;gt;
&amp;lt;link href="css/plugins/jqGrid/ui.jqgrid-bootstrap-ui.css" rel="stylesheet"&amp;gt;
&amp;lt;script&amp;gt;
$.jgrid.defaults.width = 780;
$.jgrid.defaults.responsive = true;
$.jgrid.defaults.styleUI = ‘Bootstrap’;
&amp;lt;/script&amp;gt;
&amp;lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;meta charset="utf-8" /&amp;gt;
&amp;lt;title&amp;gt;jqGrid Loading Data – Column Reordering&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;style type="text/css"&amp;gt;
/* set the size of the datepicker search control for Order Date*/
#ui-datepicker-div { font-size:11px; }
/* set the size of the autocomplete search control*/
.ui-menu-item {
}
.ui-autocomplete {
font-size: 11px;
}
&amp;lt;/style&amp;gt;
&amp;lt;table id="jqGrid"&amp;gt;&amp;lt;/table&amp;gt;
<div></div>
&amp;lt;script type="text/javascript"&amp;gt;
$(document).ready(function () {
var filter;
$("#jqGrid").jqGrid({
url: ‘data.json’,
mtype: "GET",
datatype: "json",
colModel: [
{ label : "Order ID",
//sorttype: ‘integer’,
name: ‘OrderID’,
key: true,
width: 75 ,
colmenu : true,
coloptions : {sorting:true, columns: true, filtering: true, seraching:true, grouping:false, freeze : true},
searchoptions : {
searchOperMenu : false,
sopt : [‘eq’,’gt’,’lt’,’ge’,’le’]
}
},
{
label: "Customer ID",
name: ‘CustomerID’,
width: 150,
hidedlg : true,
// stype defines the search type control – in this case HTML select (dropdownlist)
stype: "select",
// searchoptions value – name values pairs for the dropdown – they will appear as options
searchoptions: {
value: " :[All];ALFKI:ALFKI;ANATR:ANATR;ANTON:ANTON;AROUT:AROUT;BERGS:BERGS;BLAUS:BLAUS;BLONP:BLONP;BOLID:BOLID;BONAP:BONAP;BOTTM:BOTTM;BSBEV:BSBEV;CACTU:CACTU;CENTC:CENTC;CHOPS:CHOPS;COMMI:COMMI;CONSH:CONSH;DRACD:DRACD;DUMON:DUMON;EASTC:EASTC;ERNSH:ERNSH;FAMIA:FAMIA;FOLIG:FOLIG;FOLKO:FOLKO;FRANK:FRANK;FRANR:FRANR;FRANS:FRANS;FURIB:FURIB;GALED:GALED;GODOS:GODOS;GOURL:GOURL;GREAL:GREAL;GROSR:GROSR;HANAR:HANAR;HILAA:HILAA;HUNGC:HUNGC;HUNGO:HUNGO;ISLAT:ISLAT;KOENE:KOENE;LACOR:LACOR;LAMAI:LAMAI;LAUGB:LAUGB;LAZYK:LAZYK;LEHMS:LEHMS;LETSS:LETSS;LILAS:LILAS;LINOD:LINOD;LONEP:LONEP;MAGAA:MAGAA;MAISD:MAISD;MEREP:MEREP;MORGK:MORGK;NORTS:NORTS;OCEAN:OCEAN;OLDWO:OLDWO;OTTIK:OTTIK;PERIC:PERIC;PICCO:PICCO;PRINI:PRINI;QUEDE:QUEDE;QUEEN:QUEEN;QUICK:QUICK;RANCH:RANCH;RATTC:RATTC;REGGC:REGGC;RICAR:RICAR;RICSU:RICSU;ROMEY:ROMEY;SANTG:SANTG;SAVEA:SAVEA;SEVES:SEVES;SIMOB:SIMOB;SPECD:SPECD;SPLIR:SPLIR;SUPRD:SUPRD;THEBI:THEBI;THECR:THECR;TOMSP:TOMSP;TORTU:TORTU;TRADH:TRADH;TRAIH:TRAIH;VAFFE:VAFFE;VICTE:VICTE;VINET:VINET;WANDK:WANDK;WARTH:WARTH;WELLI:WELLI;WHITC:WHITC;WILMK:WILMK;WOLZA:WOLZA"
}
},
{
label: "Order Date",
name: ‘OrderDate’,
width: 150,
sorttype:’date’,
formatter: ‘date’,
srcformat: ‘Y-m-d’,
stype : ‘text’,
newformat: ‘n/j/Y’,
searchoptions: {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).datepicker({
id: ‘orderDate_datePicker’,
dateFormat: ‘m/d/yy’,
//minDate: new Date(2010, 0, 1),
maxDate: new Date(2020, 0, 1),
showOn: ‘focus’
});
}
}
},
{
label : "Ship Name",
name: ‘ShipName’,
width: 150,
searchoptions: {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).autocomplete({
id: ‘AutoComplete’,
source: function(request, response){
this.xhr = $.ajax({
url: ‘http://trirand.com/blog/phpjqgrid/examples/jsonp/autocompletep.php?callback=?&amp;amp;acelem=ShipName’,
data: request,
dataType: "jsonp",
success: function( data ) {
response( data );
},
error: function(model, response, options) {
response([]);
}
});
},
autoFocus: true
});
},
sopt : [‘cn’]
}
},
{
label: "Freight",
sorttype: ‘number’,
name: ‘Freight’,
width: 150,
sopt : [‘eq’]
},
],
loadonce: true,
viewrecords: true,
width: 780,
height: 250,
rowNum: 10,
colMenu : true,
shrinkToFit : true,
pager: "#jqGridPager"
});
// activate the toolbar searching
$(‘#jqGrid’).jqGrid(‘filterToolbar’,{
stringResult: true,
//searchOnEnter: false,
searchOperators : true
});
$(‘#jqGrid’).jqGrid(‘navGrid’,"#jqGridPager", {
search: false, // show search button on the toolbar
add: false,
edit: false,
del: false,
refresh: true
});
$("#save").click(function(){
filter = $("#jqGrid").jqGrid(‘getGridParam’, ‘postData’).filters;
var perm = [ 1, 0, 2, 4, 3 ];
$("#jqGrid").jqGrid(‘remapColumns’, perm, true, false);
console.log($("#jqGrid").jqGrid(‘getGridParam’,’colModel’));
});
$("#load").click(function(){
console.log(filter);
$("#jqGrid").jqGrid(‘refreshFilterToolbar’, {
filters : filter,
onClearVal: function ( elem, name) {
if(name === ‘CustomerID’) {
console.log(elem);
elem.multiselect(‘refresh’);
}
},
onSetVal: function ( elem, name) {
if(name === ‘CustomerID’) {
console.log(elem);
elem.multiselect(‘refresh’);
}
}
});
});
var timer;
$("#search_cells").on("keyup", function() {
var self = this;
if(timer) { clearTimeout(timer); }
timer = setTimeout(function(){
//timer = null;
$("#jqGrid").jqGrid(‘filterInput’, self.value);
},0);
});
});
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&amp;nbsp;
[/code]
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top