New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateRange as GridView filter disappears after pjax request #48
Comments
I can't say for sure, but you probably need to update your search model to account for the value from the datepicker in your database query. The value submitted from the datepicker widget needs to be parsed so you can compare the start date and end date of the range to your delivery_date field. Something like the following probably needs to be added to your search model.
|
Please, do you send de InvoiceSearch or check it //this is attribute of filter input:
public $dealerAvailableDate;
...
if (!is_null($this->dealerAvailableDate) &&
strpos($this->dealerAvailableDate, ' - ') !== false ) {
list($start_date, $end_date) = explode(' - ', $this->dealerAvailableDate);
$query->andFilterWhere(['between', 'date(dealer_available.date)', $start_date, $end_date]);
} View: [
'label' => Yii::t('app', "Appointment Date"),
'attribute' => 'dealerAvailableDate',
'value' => 'dealerAvailable.date',
'format' => 'datetime',
'filter' => DateRangePicker::widget([
'model' => $searchModel,
'attribute' => 'dealerAvailableDate',
'convertFormat' => true,
'pluginOptions' => [
'locale' => [
'format' => 'Y-m-d'
],
],
]),
], |
I've used your above solution but it not working to me. I've used the following way to achieve this.
|
I've got the same problem, it works when I set the 'pjax' value to false in the grid, otherwise after a pjax reload, the daterange does not initialize. Any workarounds for this? |
I've got the same problem... |
Hi, I have the same problem. The binding of the daterangepicker is lost after pjax. I then set 'pjax'=>false...response still acceptable even if not elegant. Also i tried this but it generated a bad side effect (but it proves the bind loose after pjax refresh). |
@kartik-v Same Issue here. It seems that there is problem between pjax and date-range. There is a redirect after I select date range, it returns to the default value. |
Maybe you should use DatePicker instead. Check this out http://dennis2society.de/yii-2-redirect-on-krajee-datepicker-changedate-event Use "GET" parameter I solve my problem. @fabioaccetta |
same problem here. |
@kartik-v Thanks |
Will need to check and figure out for this plugin for a pjax scenario when I get time. |
Folks I reviewed this issue. A mentioned in this comment in #72 and as bariew mentioned
Closing this. |
Hola dejare mi respuesta en español porque no soy bueno en el ingles. Bueno igual tuve mucho problemas pero el error que me aparece a mi era simple de solucionar tengo el siguiente codigo en la carpeta modelo en el archivo ServicioSearch $query->andFilterWhere(['like', 'estado', $this->estado]);
y este codigo pertenece al gridView: [
Todo esto me funciona perfectamente y no tuve que meterme al kartik o al js, pero me costo darme cuenta que tenia que sacar la fecha del siguiente codigo (yo la comente como podrán ver en la siguiente imagen) $query->andFilterWhere([ Espero que le sirva, se que este post es del 2015 y el ultimo es del 2017, pero espero que si encuentran este post le ahorre trabajo de alguna manera saludos a todos y suerte en todo!. |
On my application happen a strange thing. Here is the general settings:
[
|
I have an
Invoice
model (with itsInvoiceSearch
one extending it) having adelivery_date
field. I'm trying to use theDateRangePicker
widget to filter myyii\grid\GridView
.DateRangePicker
configuration is:so I use it in my column definition:
Widget works only the first time (i.e. calendar appears and after date selection the pjax request starts), but after the response replaces the grid view with the filtered one, date range picker is no more shown. Inspecting the pjax response, there is no new
daterangepicker_<hash>
inside the html, while the input field has a new config data reference instead.P.S.: if I replace config with this:
widget dates are not correctly parsed and appear like this:
p12p:2015-08-18
instead of2015-08-18
(always disappearing after the first request as before).Do I miss something?
The text was updated successfully, but these errors were encountered: