Skip to content
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

Run MarkDisabled function manually #1325

Open
masaanli opened this issue Feb 20, 2017 · 5 comments
Open

Run MarkDisabled function manually #1325

masaanli opened this issue Feb 20, 2017 · 5 comments

Comments

@masaanli
Copy link

Bug description:

I don't know if this is a bug or not.

Now when a month in a datepicker is rendered the [markDisabled]. So when you have 3 months which you display, you have 90~ days. 90 times the markDisabled is fired and this is OK.

But now when I select a date for example (in an already rendered datepicker) I want to disable some dates again. My first thought was that I can run a function on the datepicker #template like setDisabledOnDays, but there is not a kind of function like that.

As a work arround iIdid the trick below! To Reinitialize the disabled days.

  private markDisabled() {
    this.dpDate.navigateTo({
      year: this.dpDate.months[0].year,
      month: this.dpDate.months[0].number - 3
    });

    this.dpDate.navigateTo({
      year: this.dpDate.months[0].year,
      month: this.dpDate.months[0].number + 3
    });
  }

Idea to create a function to run the markDisabled again?

Link to minimally-working plunker that reproduces the issue:

You can fork a plunker from one of our demos and use it as a starting point.
Please note that we can not act on bug reports without a minimal reproduction scenario in plunker. Here is why:
https://github.com/ng-bootstrap/ng-bootstrap#you-think-youve-found-a-bug

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 2.3.5

ng-bootstrap:
20

Bootstrap:
6

@masaanli masaanli changed the title Run MarkDisabled function when Run MarkDisabled function manually Feb 20, 2017
@maxokorokov
Copy link
Member

Hey @masaanli I'm aware of the issue. But I really don't want to create a datepicker.updateDisabledDays()-kind of API for this.

Trying different solutions, but would be really interested to have some details on your use case. Am I right that for you re-running markDisabled after selected date changes would be enough?

@masaanli
Copy link
Author

masaanli commented Mar 14, 2017

@maxokorokov true it is enough for now, but performance wise not good offcourse :)

@timmyrosen
Copy link

I agree this is much required function. To be able to enable/disable days as you please is essential in many cases, including mine. When creating a date range for example, some days can be selected from but not to, and vice versa. Has anyone managed to create a solution for this?

@maxokorokov
Copy link
Member

@timmyrosen, a workaround might be to provide a new instance of the markDisabled function when you want the changes to be taken into account. Ugly, but should work.

Here is the stackblitz: https://stackblitz.com/edit/angular-li9grd

@yidingww
Copy link

a workaround might be to provide a new instance of the markDisabled function when you want the changes to be taken into account

@maxokorokov

This works when u set [markDisabled] to the <ngb-datepicker>, but it does NOT work with the popup version (bind ngbDatepicker to an <input>).

I think it's better to allow call markDisabled function manually. Or, can just make [markDisabled] function to be called eagerly (whenever user click any cells)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants