我无法在网上找到有关以下问题的任何提示: 重新排序使用下拉框(包含相关搜索词)的列后,我无法再清除工具栏中的选定值(带x)。
这可能是jqGrid中未检测到的错误吗?
我感谢任何帮助! 非常感谢。
我使用jqGrid 4.7.0:
<script type="text/javascript">
//<![CDATA[
$(document).ready(function (){
// Hilfsvariablen
var selRowData = null;
var bLinkedTables = false;
var sLoginStatus = "public";
var bColumnChooser_CustomersOverview = false;
var iColumnIndex;
var iColumnNewWidth;
// Hauptfunktion :: Definition der Tabelle BVB-Kundenuebersicht
jQuery("#list_CustomersOverview").jqGrid({
url:'./jqGridResults/xmlCustomersOverview.jsp',
datatype:"xml",
mtype: "POST",
colNames:[
'KB-Id',
'Kunde (Vollbez.)',
'Kundenbibl. (Vollbez.)',
'Kunde (Kurzbez.)',
'Kundenbibl. (Kurzbez.)',
'Straße',
'PLZ',
'Ort',
'Typ',
'ISIL',
'Sigel',
'LOW',
'Leit-ISIL'
],
colModel:[
{
name: 'libraries_id',
index:'libraries.id',
id:'libraries.id',
width:70,
hidedlg: true,
hidden:true,
editable:false,
searchoptions:{sopt:['eq','ne','le','lt','gt','ge']}
},
{
name: 'customers.name_full',
index:'customers.name_full',
width:255,
editable:true,
editoptions:{
placeholder:"Vollbezeichnung",
defaultValue:function(){
var sSelRowData = JSON.stringify(selRowData);
var obj = jQuery.parseJSON(sSelRowData);
return selRowData === null ? '' :obj["customers.name_full"];
}
},
editrules:{
edithidden:true,
required:true,
custom: true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en'], searchhidden:true},
formoptions:{label:'Kunde (Vollbez.) <span style="color:red;">*</span>'}
},
{
name: 'libraries.name_full',
index:'libraries.name_full',
width:150,
editable:true,
editrules:{
edithidden:true,
custom: true,
custom_func:validateInput
},
editoptions:{placeholder:"Vollbezeichnung"},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en'],searchhidden: true},
},
{
name: 'customers.name_short',
index:'customers.name_short',
width:255,
editable:true,
editrules:{
edithidden:true,
custom:true,
custom_func:validateInput
},
editoptions:{placeholder:"Kurzbezeichnung"},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en'],searchhidden: true},
hidden:true
},
{
name: 'libraries.name_short',
index:'libraries.name_short',
width:150,
editable:true,
editrules:{
edithidden:true,
custom:true,
custom_func:validateInput
},
editoptions:{placeholder:"Kurzbezeichnung"},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en'],searchhidden: true},
hidden:true
},
{
name: 'libraries.location_street',
index:'libraries.location_street',
width:120,
editable:true,
editrules:{
custom:true,
custom_func:validateInput
},
editoptions:{placeholder:"Hauptsitz"},
formoptions:{label:"Straße und Hausnr."},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']}
},
{
name: 'libraries.location_zip',
index:'libraries.location_zip',
width:82,
editable:true,
editrules:{
custom:true,
custom_func:validateInput
},
editoptions:{placeholder:"z.B. 12345"},
searchoptions:{sopt:['bw','bn','eq','ne']},
},
{
name: 'libraries.location_city',
index:'libraries.location_city',
width:105,
editable:true,
editoptions:{placeholder:"Stadt"},
editrules:{
custom:true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']}
},
{
name: 'libraries.type_of_institution',
index:'libraries.type_of_institution',
width:115,
editable:true,
edittype:"select",
editoptions:{value:"B:Behördenbibliothek;F:Fachhochschulbibliothek;H:Hochschulbibliohek;K:Kirchliche Bibliothek;Ö:Öffentliche Bibliothek;R:Regional Staatliche Bibliothek;S:Spezialbibliothek;U:Universitätsbibliothek;Z:Zweigbibliothek"},
stype:'select',
searchoptions:{sopt:['eq','ne'], value:":Alle;B:Behördenbibliothek;F:Fachhochschulbibliothek;H:Hochschulbibliohek;K:Kirchliche Bibliothek;Ö:Öffentliche Bibliothek;R:Regional Staatliche Bibliothek;S:Spezialbibliothek;U:Universitätsbibliothek;Z:Zweigbibliothek"}
},
{
name: 'libraries.icode_isil',
index:'libraries.icode_isil',
width:85,
editable:true,
editoptions:{placeholder:"z.B. DE-M37"},
editrules:{
custom:true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']},
},
{
name: 'libraries.icode_sigel',
index:'libraries.icode_sigel',
width:85,
editable:true,
editoptions:{placeholder:"z.B. M 37"},
editrules:{
custom:true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']},
},
{
name: 'libraries.icode_low',
index:'libraries.icode_low',
width:85,
editable:true,
editoptions:{placeholder:"z.B. DAV01"},
editrules:{
custom:true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']},
},
{
name: 'libraries.icode_isil_of_leader_lib',
index:'libraries.icode_isil_of_leader_lib',
width:85,
editable:true,
editoptions:{placeholder:"z.B. DE-19"},
editrules:{
custom:true,
custom_func:validateInput
},
searchoptions:{sopt:['bw','bn','cn','nc','eq','ne','ew','en']},
},
],
// Tabellenbreite proportional anpassen
shrinkToFit: false,
// Spalten via Maustaste umordnen
sortable: true,
// ID der Navigationsleiste
pager: "#pager_CustomersOverview",
// Ueberschrift
caption: "BVB-Kundenübersicht",
// Initiale Inhaltssortierung
sortname: "customers.name_full",
// Initiale Sortierrichtung
sortorder: "asc",
// Zebrastreifen
altRows: true,
// Zeilen highlighten (z.B. bei onmouseover)
hoverrows: true,
// Tabellenhoehe
height: "230",
// Anzahl der angezeigten Tupel auf einer Tabellenseite
rowNum: 1000,
// Initialer Tabellenzustand
hiddengrid: false,
// Anzeige der Tupelnummer
rownumbers: true,
// Optionale Tupelanzahl pro Tabellenseite
rowList: [1000,500,100,50,20,10],
// Anzeige "Zeige X bis Y aus Z" in der PagerBar
viewrecords: true,
// Alle Daten werden auf einmal geladen (Speedvorteil)
gridview: true,
// Automatisches HTML-Encoding
autoencode: true,
//
prmNames: {id:'libraries.id'},
editurl:"./jqGridResults/xmlCustomersOverview.jsp",
onSelectRow: function(ids){
var $self = $("#list_Contacts");
if(bLinkedTables == true){
if(ids != null){
if(ids.length == 0){
$self.jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?libraries_id=0&bLinkedTables="+bLinkedTables}).trigger('reloadGrid');
}else if(ids.length == 10){
$self.jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?libraries_id="+ids+"&bLinkedTables="+bLinkedTables}).trigger('reloadGrid');
}
$self.jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?bLinkedTables="+bLinkedTables});
}
}
},
resizeStop: function (newWidth, iCol) {
var $self = $(this);
$self.jqGrid("setColWidth", iCol, newWidth);
shrinkToFit = $self.jqGrid("getGridParam", "shrinkToFit");
$self.jqGrid("setGridWidth", this.grid.newWidth, shrinkToFit);
},
loadComplete: function(){
//Wenn Tabellenverknüpfung aktiv ist
var userdata = jQuery("#list_Contacts").jqGrid('getGridParam', 'userData');
if(userdata.linkedTables === 'true'){
jQuery("#list_Contacts").jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?libraries_id=0&bLinkedTables="+userdata.linkedTables}).trigger('reloadGrid');
//jQuery("#list_Contacts").jqGrid('setCaption',"Selektieren Sie einen Datensatz aus der BVB-Kundenübersicht, um lokale Ansprechpartner zu finden.");
}
var $self = $(this);
var aCustomersOverviewIds = $self.jqGrid("getDataIDs");
var hLibTypesFull = new Object();
hLibTypesFull['B'] = "Behördenbibliothek";
hLibTypesFull['F'] = "Fachhochschulbibliothek";
hLibTypesFull['H'] = "Hochschulbibliohek";
hLibTypesFull['K'] = "Kirchliche Bibliothek";
hLibTypesFull['Ö'] = "Öffentliche Bibliothek";
hLibTypesFull['R'] = "Regional Staatliche Bibliothek";
hLibTypesFull['S'] = "Spezialbibliothek";
hLibTypesFull['U'] = "Universitätsbibliothek";
hLibTypesFull['Z'] = "Zweigbibliothek";
for(var i = 0; i < aCustomersOverviewIds.length; i++){
var sLibTypeShort = $self.jqGrid('getCell',aCustomersOverviewIds[i],"libraries.type_of_institution");
$self.jqGrid('setCell',aCustomersOverviewIds[i],"libraries.type_of_institution", hLibTypesFull[sLibTypeShort]);
}
// JSON-Objecte zur Anzeigensteuerung der Buttons in der Navigationsleiste
var oOptionsPrivate = {edit:true, add:true, del:true, search:true, view:true, refresh:true};
var oOptionsPublic = {edit:false, add:false, del:false, search:true, view:true, refresh:true};
// Button-Konfiguration :: Editieren
var oConfEdit = {
closeAfterEdit:false,
width: 'auto',
afterSubmit: function (response){
return generateSuccesssMessage(response,"edit", $.jgrid.jqID(this.id));
},
errorTextFormat:function(data){
return generateErrorMessage(data,"edit");
}
};
// Button-Konfiguration :: Hinzufuegen
var oConfAdd = {
closeAfterAdd:false,
reloadAfterSubmit:true,
closeOnEscape:true,
width: 'auto',
beforeInitData: function () {
var rowidCustomersOverview = $self.jqGrid('getGridParam','selrow');
if(rowidCustomersOverview !== null){
selRowData = $self.jqGrid('getRowData', rowidCustomersOverview);
}else{
selRowData = null;
}
},
afterSubmit: function (response){
return generateSuccesssMessage(response,"add", $.jgrid.jqID(this.id));
},
errorTextFormat:function(data){
return generateErrorMessage(data,"add");
}
};
// Button-Konfiguration :: Loeschen
var oConfDelete = {
reloadAfterSubmit:false,
closeAfterEdit:false,
width: "auto",
errorTextFormat: function(data){
return generateErrorMessage(data,"delete");
}
};
// Button-Konfiguration :: Suchen
var template1 =
{ "groupOp": "AND",
"rules": [
{ "field": "libraries.icode_isil_of_leader_lib", "op": "bw", "data": ""},
{ "field": "libraries.location_city", "op": "bw", "data": ""}
]
};
var template2 =
{ "groupOp": "AND",
"rules": [
{ "field": "libraries.type_of_institution", "op": "bw", "data": "" },
{ "field": "libraries.location_city", "op": "bw", "data": ""}
]
};
var oConfSearch = {
multipleSearch:true,
afterShowSearch:function(){$self[0].clearToolbar()},
closeAfterSearch:true,
showQuery:false,
multipleGroup:false,
caption:"BVB-Kundenübersicht :: Erweiterte Suche",
tmplNames: ["Leit-ISIL und Ort","Typ und Ort"],
// set the template contents
tmplFilters: [template1, template2]
};
// Button-Konfiguration :: Anzeige
var oConfView = {
width: '700',
};
// Steuerung der Butttons in der Navigationsleiste (privater vs. oeffentlicher Bereich)
<%
// Liegt die aktuelle SessionID bereits vor in validsessions?
if(res.first()){
%>
$self.jqGrid('navGrid','#pager_CustomersOverview', oOptionsPrivate, oConfEdit, oConfAdd, oConfDelete, oConfSearch, oConfView, {});
$self.jqGrid("showCol","libraries_id");
var newWidthContacts = $self.jqGrid("getGridParam","width");
if(newWidthContacts === 1265){
var extraWidth = newWidthContacts + 75;
$self.jqGrid("setGridWidth", extraWidth, false);
}else{
$self.jqGrid("setGridWidth", newWidthContacts, false);
}
<%
}else{
%>
$self.jqGrid('navGrid','#pager_CustomersOverview', oOptionsPublic, {}, {}, {}, oConfSearch, oConfView, {});
$self.jqGrid("hideCol","libraries_id");
var newWidthContacts = $self.jqGrid("getGridParam","width");
$self.jqGrid("setGridWidth", newWidthContacts, false);
<%
}
%>
// Custom Button :: ColumnChooser
if(bColumnChooser_CustomersOverview == false){
$self.jqGrid("navButtonAdd", "#pager_CustomersOverview", {
caption: "",
buttonicon: "ui-icon-calculator",
title: "Spalten auswählen",
onClickButton: function () {
$(this).jqGrid("columnChooser",{
modal:true,
done : function (perm) {
if (perm){
this.jqGrid("remapColumns", perm, true);
this.trigger('reloadGrid');
}
}
});
}
});
bColumnChooser_CustomersOverview = true;
}
// Button-Separator
// $('#list_CustomersOverview').jqGrid('navSeparatorAdd',"#pager_CustomersOverview",{ sepclass: 'ui-separator', sepcontent: ''});
// Custom Button :: ResetColumn-Button
$self.jqGrid('navButtonAdd','#pager_CustomersOverview',{
caption: "",
buttonicon: "ui-icon-close",
id:"customButtonReset",
title: "Tabellen zurücksetzen",
position: "Reset",
onClickButton: function(){
window.location.reload();
}
});
// Zusatzfunktion :: Schalter zur Verknuepfung der Tabellen. Selektion einer Zeile in Kundenuebersicht loest Suche in Lokale Ansprechpartner aus
var bRadioButton = false;
var sTitleBeforeClickRadio = "Tabellenverknüpfung aktivieren";
var sTitleAfterClickRadio = "Tabellenverknüpfung deaktivieren";
var iconOff = "ui-icon-radio-on";
// Custom Buttom :: Radio
$self.jqGrid('navButtonAdd',"#pager_CustomersOverview",{
caption:"",
title:sTitleBeforeClickRadio,
buttonicon:iconOff,
id:"customButtonRadio",
onClickButton:function(){
if(bRadioButton == false){
bLinkedTables = true;
jQuery("#customButtonRadio").attr('title',sTitleAfterClickRadio);
jQuery(".ui-icon.ui-icon-radio-on").removeClass("ui-icon-radio-on").addClass("ui-icon-bullet");
//TEST bLinkedTables Parameter
jQuery("#list_Contacts").jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?libraries_id=0&bLinkedTables="+bLinkedTables});
var sGridContacts = jQuery("#list_Contacts");
sGridContacts[0].clearToolbar();
//TEST
jQuery("#search_list_Contacts").hide();
jQuery("#refresh_list_Contacts").hide();
jQuery("tr[class='ui-search-toolbar']:last").hide();
//TEST bLinkedTables Parameter
jQuery("#list_Contacts").jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?bLinkedTables="+bLinkedTables});
bRadioButton = true;
}else{
bLinkedTables = false;
jQuery("#customButtonRadio").attr('title',sTitleBeforeClickRadio);
jQuery(".ui-icon.ui-icon-bullet").removeClass("ui-icon-bullet").addClass("ui-icon-radio-on");
//TEST
jQuery("#list_Contacts").jqGrid('setGridParam',{url:"./jqGridResults/xmlLibrariesContacts.jsp?bLinkedTables="+bLinkedTables});
jQuery("#search_list_Contacts").show();
jQuery("#refresh_list_Contacts").show();
jQuery("tr[class='ui-search-toolbar']:last").show();
jQuery("#list_Contacts").trigger('reloadGrid');
bRadioButton = false;
}
}
});
// Custom Button :: Hilfe
$self.jqGrid('navButtonAdd','#pager_CustomersOverview',{
caption: "Hilfe",
buttonicon: "ui-icon-arrowthickstop-1-s",
id:"instructionManual",
title: "Download Bedienungsanleitung",
position: "last",
onClickButton: function(){
window.open("./documents/BVB_CDB_INSTRUCTION_MANUAL.pdf","_blank");
}
});
$self.jqGrid("navGrid", "#pager_CustomersOverview");
$("#view_list_CustomersOverview").insertAfter("#search_list_CustomersOverview");
var ids = $self.jqGrid('getDataIDs');
var sortName = $self.jqGrid('getGridParam','sortname');
var sortOrder = $self.jqGrid('getGridParam','sortorder');
var mymodelCustomers = $self.jqGrid('getGridParam','colModel');
$.each(mymodelCustomers, function(i){
if(this.name == sortName && this.hidden == false){
if (ids) {
for (var i=0;i<ids.length;i++) {
$self.jqGrid('setCell', ids[i], sortName, '', '',
{style:(sortOrder==='asc'?'background:#fbec88;':
'background:#fbec88;')});
}
}
}
});
//Mindestgroesse Tabelle
var gridWidth = $self.jqGrid("getGridParam","width");
if(gridWidth <= 500){
$self.jqGrid("setGridWidth",550);
$self.trigger("reloadGrid");
}
}
});
// Zusatzfunktion :: Steuerung ueber Tastatur aktivieren
jQuery("#list_CustomersOverview").jqGrid('bindKeys');
// Zusatzfunktion :: Toolbarsuche mit datenspezifischen Suchoperatoren einbinden
jQuery("#list_CustomersOverview").jqGrid('filterToolbar',{stringResult:true, searchOnEnter:false, searchOperators:true});
// Zusatzfunktion: Toolbarsuche nach paste ausloesen
jQuery("#gbox_list_CustomersOverview input[id^='gs_']").attr("onpaste","triggerToolbar('#list_CustomersOverview')");
// Zusatzfunktion :: Hinzufuegen einer Division zur Informationsausgabe auf der ToolBar
jQuery("<div><span id='list_InfoToolBar' style:'float:left;'></span></div>").appendTo("#t_list_CustomersOverview");
jQuery("#pager_CustomersOverview .ui-pg-selbox").closest("td").before("<td dir='ltr'>max.</td>");
jQuery("#pager_CustomersOverview .ui-pg-selbox").closest("td").after("<td dir='ltr'>Datensätze pro Seite anzeigen</td>");
});
//]]>
</script>