kartik-v / yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
http://demos.krajee.com/date-range
Other
93 stars 81 forks source link

Infinite refresh of grid view after last update #52

Closed ekzobrain closed 9 years ago

ekzobrain commented 9 years ago

After updating to v1.6.4 my grid view is refreshing infinitely. I use daterangepicker as a filter for datetime column. Default filter value is empty, but after page load some value is inserted into filter input and grid form is submitted.

ekzobrain commented 9 years ago

Also, convertFormat class variable is not defined in class DateRangePicker leading to increased memory usage by that class object. Also, documentation about pluginOptions['format'] param should be updated, till it was moved to pluginOptions['locale']['format'] by 1.6.4 update.

ekzobrain commented 9 years ago

I was able to overcome this issue by setting autoUpdateInput daterangepicker option to True. But now I have to provide a callback to manually set input's value. Seem like new version of the plugin does not like empty startDate and endDate values and if they are not provided - sets them automatically to some default value, and updates input - so filter form is submitted. The only two solutions that I see are:

  1. Provide default value for filter input (not always appropriate)
  2. Set autoUpdateInput to false and always provide a callback (if not provided by user) for setting input value These settings a related not to dateragepicker widget itself, but only when it is used as a filter in GridView, so I think, that GridView class should set these options.
kartik-v commented 9 years ago

Also, documentation about pluginOptions['format'] param should be updated, till it was moved to pluginOptions['locale']['format'] by 1.6.4 update.

This was already updated in docs with the update. Release v1.6.4 uses the latest release 2.1.3 of the bootstrap-daterangepicker plugin - so you must change your code as per the source plugin changes.

Also refer Release v1.6.4 notes.

These settings a related not to daterangepicker widget itself, but only when it is used as a filter in GridView, so I think, that GridView class should set these options.

I feel each developer rather needs to configure it for their need using the GridView filter Widget Options based on their use case. If you have any suggestions for enhancement let know.

ekawalec commented 9 years ago

I've the same issue, version number doesn't suggest such changes ... add necesary config option to override this (autoUpdateInput), please :)

XzAeRo commented 9 years ago

Same problem here.

The plugin tries to set a daterange automatically in the input.

ekawalec commented 9 years ago

@XzAeRo downgrade to 1.6.3 - works fine until @kartik-v will make some changes :))

XzAeRo commented 9 years ago

@ekawalec thanks!

kartik-v commented 9 years ago

Note that the options like autoUpdateInput is an update to the source plugin and new config options and changes to plugin settings are to be referred in the plugin docs (or you need to reach out to the plugin author if you have feedback or suggestions for the plugin). On your query of where to set in this widget -- all plugin properties can be set within the widget's pluginOptions - so I am not clear where the issue is.

I can include a link to refer the plugin updates in the docs. Will probably try and see if I can default some settings - but again its left to each developer's use case how they want to configure it.

kartik-v commented 9 years ago

It seems a problem with source plugin that sets null values to a default current date and I think I will evaluate the suggestion by @soulhunter1987

  1. Provide default value for filter input (not always appropriate)
  2. Set autoUpdateInput to false and always provide a callback (if not provided by user) for setting input value
kartik-v commented 9 years ago

Ok this is fixed via update to release v1.6.5 (currently in dev-master).

New property autoUpdateOnInit is added to the widget which defaults to false. If set to false it will override the plugin's default behavior of setting a value on Initialization and triggering the change causing the infinite loop.

XzAeRo commented 9 years ago

@kartik-v thank you!

ekzobrain commented 9 years ago

Thanks, seems to work OK now. It may be not a problem, but an expected behavior of source plugin. But it may also be a bug. I will open an issue there and provide a link to it.