twinssbc / Ionic2-Calendar

A calendar component based on Ionic framework
https://ionic-calendar-demo.stackblitz.io
MIT License
388 stars 197 forks source link

How can enable and disable the previous days and after days? #60

Closed gsaikrishna32 closed 4 years ago

gsaikrishna32 commented 7 years ago

I want to enable and disable the dates and also how can i display this calendar(UI) in pop up.

twinssbc commented 7 years ago

@gsaikrishna32 You can check markDisabled option in README.

gsaikrishna32 commented 7 years ago

can I display the calendar in pop up?

gsaikrishna32 commented 7 years ago

sry bro i had got calendar but how i wanted to display it in pop up

twinssbc commented 7 years ago

@gsaikrishna32 What kind of popup are you using? Is it an Ionic component? I think you just need to declare the calendar in the popup page. It may require some css tuning depending on the popup component you use. But I personally don't like popup, as the mobile phone is already very small, if you want to display something in a popup window, it's not easy to select things inside that window.

amulyadande commented 7 years ago

disabling the dates is not working fyn can u send me the changes in markDisabled option

twinssbc commented 7 years ago

@amulyadande Did you try the code snippet in README?

<calendar ... [markDisabled]=“markDisabled”></calendar>

  markDisabled = (date: Date) => {
      var current = new Date();
      return date < current;
  };
amulyadande commented 7 years ago

i wrote the same code what actually u sent to me bt it is not responding anything, it is showing blank page no output nd no errors

On Thu, Mar 23, 2017 at 7:52 PM, twinssbc notifications@github.com wrote:

@amulyadande https://github.com/amulyadande Did you try the code snippet in README?

<calendar ... [markDisabled]=“markDisabled”>

markDisabled = (date: Date) => { var current = new Date(); return date < current; };

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/twinssbc/Ionic2-Calendar/issues/60#issuecomment-288734462, or mute the thread https://github.com/notifications/unsubscribe-auth/AZYzG8C2onWNFoStwNpe8wfixbolksGOks5rooAogaJpZM4MG-Gp .

twinssbc commented 7 years ago

If you remove the markDisabled attribute, does it display correctly?

ALSephirot commented 7 years ago

I have the same problem, the markDisabled event only fires when I select the date or time, but I want to hide it when rendering or disabling the tap event and putting it in another color

twinssbc commented 7 years ago

@ALSephirot markDisabled should be fired when rendering. Is it possible you bind markDisabled to some timeSelected event?

gmarab commented 7 years ago

Sorry @twinssbc , but markDisabled is never called during rendering. By looking at the code I see that the only call is made in the select method of the views. For example, for WeekViewComponent at line 366.

twinssbc commented 7 years ago

@gmarab markDisabled is called when rendering the monthview, not applicable to the weekview and dayview.

frixtiglao commented 6 years ago

@twinssbc is there a way to disable specific dates? For example, Oct. 15, Oct 17, Oct 21, Oct 26 will the ones to be disable only in the calendar.

twinssbc commented 6 years ago

@frixtiglao You could use markDisabled callback method. You just need to check if the date argument equals to the dates you want to disable.

frixtiglao commented 6 years ago

@twinssbc I am using the call back method of the markDisabled but when I put for example "return date = current_date" it will not disable the current date rather it will disable all the dates from the calendar. If you can give a short code example on how to achieve the disabling specific dates, I would really appreciate it. Thanks in advance!

twinssbc commented 6 years ago

@frixtiglao Although they may be the same date, but == will treat them as two different objects. You need to compare them with the timestamp. For example,

    markDisabled = (date: Date) => {
        var checkDate = new Date(2017, 9, 14, 12, 0, 0);
        return date.getTime() == checkDate.getTime();
    }
frixtiglao commented 6 years ago

@twinssbc Thank you it worked! I will further test the code.

krunal9421 commented 6 years ago

@twinssbc Can we set date into ion2-calendar when it render and then select date which we want in monthview? and how to load the specific date month in ion2-calendar? for ionic 2

twinssbc commented 6 years ago

@krunal9421 Could you create a separate issue? This question is not relevant to the issue.

sachininara commented 6 years ago

Hi Can you please tell me how to block swipe 2 months before this month and 10 months after this month. Assume like now we are in April month , from calendar we can swipe to previous side up to January this year and swipe to forward side up to march next year. can you please tell me how block swiping after this months in ionic 2 calendar.

Thank you

twinssbc commented 6 years ago

@sachininara Disable swiping to previous months is easy. There's an option, lockSwipeToPrev, you could use. I didn't expose lockSwipeToNext option as I found it didn't work well. I could check again to see if Ionic team fixed it.

sachininara commented 6 years ago

@twinssbc thank you very much your response. Actually this is urgent task. If you can please tell me how to disable months after 10 months from this month.

Thank you

twinssbc commented 6 years ago

@sachininara I just tried the lockSwipeToNext option in Ionic Slides. It still doesn't work for the looped slides. So I'm afraid your requirement can't be achieved.

sachininara commented 6 years ago

Hi Thank you for your response. Actually I am thinking a way to block swiping sliders after particular range. I am in urgent task. Could you please tell me how to block swiping using calendar.js files's functions. Thank you

twinssbc commented 6 years ago

@sachininara As I said disabling swiping to next month doesn't work.

mowaiskalam commented 6 years ago

@twinssbc is there any way to disable previous days in week view. 'markDisabled' is working for me in month view. But I want to do same / disable days in week view too. Can you suggest me how can i do that?

sidoineAdanz commented 5 years ago

@mowaiskalam , did you solde that? I have the same issue