diff --git a/Grid/Filter/DateRange.php b/Grid/Filter/DateRange.php
index 1e37db5..94b4a5e 100644
--- a/Grid/Filter/DateRange.php
+++ b/Grid/Filter/DateRange.php
@@ -31,8 +31,9 @@ public function render()
} else {
- $html = ' ';
- $html .= '';
+ $html = ' ';
+ $html .= $this->getInputSeparator();
+ $html .= '';
}
diff --git a/Grid/Filter/NumberRange.php b/Grid/Filter/NumberRange.php
new file mode 100644
index 0000000..4a425ef
--- /dev/null
+++ b/Grid/Filter/NumberRange.php
@@ -0,0 +1,51 @@
+getIndex() . '[]" id="' . $this->getId() . 'from" type="text" placeholder="' . $this->getPlaceholder() . '" value="' . $this->getValue() . '"> ';
+ $html .= $this->getInputSeparator();
+ $html .= '';
+
+ return $html;
+ }
+
+ /**
+ * @param string $inputSeparator
+ *
+ * @return DateRange
+ */
+ public function setInputSeparator($inputSeparator)
+ {
+ $this->inputSeparator = $inputSeparator;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getInputSeparator()
+ {
+ return $this->inputSeparator;
+ }
+}
\ No newline at end of file
diff --git a/Grid/Filter/Operator/NumberRange.php b/Grid/Filter/Operator/NumberRange.php
new file mode 100644
index 0000000..d829313
--- /dev/null
+++ b/Grid/Filter/Operator/NumberRange.php
@@ -0,0 +1,48 @@
+getQueryBuilder();
+
+ if (!empty($value[0])) {
+ $queryBuilder->andWhere(
+ $queryBuilder->expr()->gte(
+ $this->getIndex(),
+ ":{$this->getIndexClean()}_1"
+ ))
+ ->setParameter(
+ ":{$this->getIndexClean()}_1",
+ (float) $value[0]
+ );
+ }
+
+ if (!empty($value[1])) {
+
+ $queryBuilder->andWhere(
+ $queryBuilder->expr()->lte(
+ $this->getIndex(),
+ ":{$this->getIndexClean()}_2"
+ ))
+ ->setParameter(
+ ":{$this->getIndexClean()}_2",
+ (float) $value[1]
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 1573ac7..ebe5b7c 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,11 @@ Create your grid
->setField('name')
->setIndex('r.name');
+ $this->addColumn('Number')
+ ->setField('number')
+ ->setIndex('r.number')
+ ->setFilterType('number_range');
+
$this->addColumn('Options')
->setField('option')
->setIndex('r.options')
diff --git a/Resources/doc/column/filter.md b/Resources/doc/column/filter.md
index 9c7b2a9..6131587 100644
--- a/Resources/doc/column/filter.md
+++ b/Resources/doc/column/filter.md
@@ -62,6 +62,7 @@ Operator Comparison Types:
* end_with
* not_end_with
* not_contain
+* number_range
date
------------
@@ -77,6 +78,15 @@ Attributes:
* inputSeparator
+number_range
+------------
+
+Two fields to define a number range.
+
+Attributes:
+
+* inputSeparator
+
select
------------
diff --git a/Resources/public/css/grid.css b/Resources/public/css/grid.css
index 6615d57..d4f6dfc 100644
--- a/Resources/public/css/grid.css
+++ b/Resources/public/css/grid.css
@@ -33,6 +33,10 @@
width: 75px;
}
+.pedroteixeira-grid-wrapper table thead tr th .number-input {
+ width: 75px;
+}
+
.pedroteixeira-grid-wrapper table tfoot #pagination {
font-size: 0.8em;
}
diff --git a/Resources/public/less/grid.less b/Resources/public/less/grid.less
index 0e5c345..7d824e1 100644
--- a/Resources/public/less/grid.less
+++ b/Resources/public/less/grid.less
@@ -27,6 +27,9 @@
.date-input {
width: 75px;
}
+ .number-input {
+ width: 75px;
+ }
}
}