Permalink
Browse files

Fix show/hide rule buttons when multiple search is false. Thank to Oleg.

  • Loading branch information...
1 parent b2b1dd8 commit 1f146b3da3548cc5e4a2c322784532486b961276 @tonytomov committed Jun 18, 2011
Showing with 10 additions and 16 deletions.
  1. +8 −4 js/grid.filter.js
  2. +2 −12 js/grid.formedit.js
View
@@ -72,7 +72,8 @@ $.fn.jqFilter = function( arg ) {
stropts : ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 'nu', 'nn', 'in', 'ni'],
_gridsopt : [], // grid translated strings, do not tuch
groupOps : ["AND", "OR"],
- groupButton : true
+ groupButton : true,
+ ruleButtons : true
}, arg || {});
return this.each( function() {
if (this.filter) {return;}
@@ -195,6 +196,7 @@ $.fn.jqFilter = function( arg ) {
var th = $("<th colspan='5' align='left'></th>");
tr.append(th);
+ if(this.p.ruleButtons) {
// dropdown for: choosing group operator type
var groupOpSelect = $("<select class='opsel'></select>");
th.append(groupOpSelect);
@@ -211,7 +213,7 @@ $.fn.jqFilter = function( arg ) {
group.groupOp = $(groupOpSelect).val();
that.onchange(); // signals that the filter has changed
});
-
+ }
// button for adding a new subgroup
var inputAddSubgroup ="<span></span>";
if(this.p.groupButton) {
@@ -234,7 +236,7 @@ $.fn.jqFilter = function( arg ) {
});
}
th.append(inputAddSubgroup);
-
+ if(this.p.groupButtons) {
// button for adding a new rule
var inputAddRule = $("<input type='button' value='+' title='Add rule' class='add-rule ui-add'/>"), cm;
inputAddRule.bind('click',function() {
@@ -270,6 +272,7 @@ $.fn.jqFilter = function( arg ) {
return false;
});
th.append(inputAddRule);
+ }
// button for delete the group
if (parentgroup !== null) { // ignore the first group
@@ -488,6 +491,7 @@ $.fn.jqFilter = function( arg ) {
tr.append(ruleDeleteTd);
// create button for: delete rule
+ if(this.p.ruleButtons === true) {
var ruleDeleteInput = $("<input type='button' value='-' title='Delete rule' class='delete-rule ui-del'/>");
ruleDeleteTd.append(ruleDeleteInput);
//$(ruleDeleteInput).html("").height(20).width(30).button({icons: { primary: "ui-icon-minus", text:false}});
@@ -505,7 +509,7 @@ $.fn.jqFilter = function( arg ) {
that.onchange(); // signals that the filter has changed
return false;
});
-
+ }
return tr;
};
View
@@ -82,12 +82,6 @@ $.jgrid.extend({
}
}
}
- function hideButtons()
- {
- $(".add-rule","#"+fid).hide();
- $(".delete-rule","#"+fid).hide();
- $(".opsel","#"+fid).hide();
- }
if ( $("#"+IDs.themodal).html() !== null ) {
showFilter();
} else {
@@ -153,6 +147,7 @@ $.jgrid.extend({
errorcheck : p.errorcheck,
sopt: p.sopt,
groupButton : p.multipleGroup,
+ ruleButtons : p.multipleSearch,
_gridsopt : $.jgrid.search.odata,
onChange : function( sp ) {
if(this.p.showQuery) {
@@ -172,9 +167,7 @@ $.jgrid.extend({
return false;
});
}
- if(p.multipleSearch === false) {
- hideButtons();
- }
+ if(p.multipleGroup === true) p.multipleSearch = true;
if($.isFunction(p.onInitializeSearch) ) {
p.onInitializeSearch($("#"+fid));
}
@@ -257,9 +250,6 @@ $.jgrid.extend({
if($.isFunction(p.onReset) ) {
p.onReset();
}
- if(p.multipleSearch === false) {
- hideButtons();
- }
$($t).trigger("reloadGrid",[{page:1}]);
return false;
});

0 comments on commit 1f146b3

Please sign in to comment.