This is a migrated thread and some comments may be shown as answers.

How to deselect a date in monthview

6 Answers 385 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
rincy
Top achievements
Rank 1
rincy asked on 19 Mar 2015, 11:23 AM
Hi,

In calendar month mode I want to deselect a date by taping on the selected date. 


Thanks & Regards,
Rose.

6 Answers, 1 is accepted

Sort by
0
Antony Jekov
Telerik team
answered on 20 Mar 2015, 08:52 AM
Hello Rincy,

Thank you for writing.

By default a selected cell is being deselected when taped. The only exception would be the range selection mode, where you cannot disable the first selected date.

What type of selection are you using? Single, multiple or range?

Regards,
Antony Jekov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
rincy
Top achievements
Rank 1
answered on 20 Mar 2015, 08:59 AM
I want single selection only.But couldnt find how to do single selection so am usingion so am using following code to select

 private void GoToDate(Calendar cal) {        
        List<Long> dates = new ArrayList<Long>();
        dates.add(cal.getTimeInMillis());
        calendarView.setSelectedDates(dates);        
        calendarView.setDisplayDate(cal.getTimeInMillis());
    }
0
rincy
Top achievements
Rank 1
answered on 20 Mar 2015, 09:46 AM
I got problem.

When am using CalendarSelectionMode single I couldn't deselect it.
calendarView.setSelectionMode(CalendarSelectionMode.Single);  when i remove this line i can deselect by tapping the selected . date,but calendar will allow multiple selection.Please gives me a suggestion to resolve this.

I want single selection and when tapping on selected date it should deselect.
0
Antony Jekov
Telerik team
answered on 20 Mar 2015, 05:09 PM
Hello ,

As mentioned in the private ticket you sent me, this would be a possible solution:
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final RadCalendarView calendarView = new RadCalendarView(this);
 
        calendarView.setSelectionMode(CalendarSelectionMode.Single);
        calendarView.setGestureManager(new CustomGestureManager(calendarView));
 
        setContentView(calendarView);
    }
 
    class CustomGestureManager extends CalendarGestureManager {
 
        public CustomGestureManager(RadCalendarView owner) {
            super(owner);
        }
 
        @Override
        protected void handleTapGesture(CalendarDayCell calendarCell) {
            if (calendarCell.isSelected()) {
                owner.setSelectedDates(null);
            } else {
                super.handleTapGesture(calendarCell);
            }
        }
    }

I will check with our designer and see if I can enable this by default.

Thank you for your time and all best!

Regards,
Antony Jekov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
dlhts_swam
Top achievements
Rank 1
answered on 24 Mar 2015, 04:45 AM
Hi,

Hi Antony,

Thanks for your reply.
I have tried this code before by passing null to 'setSelectedDates',But its throwing an exception I'ndexOutOfBoundsException:Invalid index 0,size 0'.I think 'setSelectedDates' wont handle null.Could you please check it out?

Thanks & Regards,
Rincy Rose
0
Antony Jekov
Telerik team
answered on 24 Mar 2015, 09:51 AM
Hello ,

Since you sent a private ticket, I am going to proceed and close this one. Please refer to the conversation there.

Regards,
Antony Jekov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Calendar
Asked by
rincy
Top achievements
Rank 1
Answers by
Antony Jekov
Telerik team
rincy
Top achievements
Rank 1
dlhts_swam
Top achievements
Rank 1
Share this question
or