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

[Solved] Limit dates

4 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keith Stephens
Top achievements
Rank 1
Keith Stephens asked on 27 Aug 2010, 02:46 PM
Hello all,
I have been working on this for a few days now with no evail.

I have a gridveiw that has 2 fields on it "begin" and "end". These fields are date types so when in edit mode the date picker is displayed.
I need to be able to limit the dates that the user can select in the date picker.
In the "begin" fields I need the user to be able to select date upto 30 days past and in the "end" field they can only select upto 90 in the future.

I don't know how to get to the date control, it is automatic?
Here is how my column is set up.
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding BeginDate, Mode=TwoWay}" >
                           <telerikGridView:GridViewDataColumn.Header>
                               <StackPanel Orientation="Vertical">
                                   <!-- This display the wording Date under Begin.-->
                                   <TextBlock  Text="Begin" HorizontalAlignment="Left" />
                                   <TextBlock  Text="Date" HorizontalAlignment="Left" />
                               </StackPanel>
                           </telerikGridView:GridViewDataColumn.Header>
                           <telerikGridView:GridViewDataColumn.CellTemplate>
                               <DataTemplate>
                                   <TextBlock Text="{Binding BeginDate, Converter={StaticResource DateTimeConverter}, ConverterParameter=d}"/>
                               </DataTemplate>
                           </telerikGridView:GridViewDataColumn.CellTemplate>
                       </telerikGridView:GridViewDataColumn>

Thanks for any help or advice.
KS

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 Aug 2010, 04:07 PM
Hi Keith Stephens,

You may define a RadDatePicker inside the  CellTemplate/CellEditTemplate and use its properties SelectableDateStart and SelectableDateEnd, which corresponds to the date allowed for start/end. You may take a look at our demos for a reference. Another possible approach may be to define your own custom validation as demonstrated in our online documentation.

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Keith Stephens
Top achievements
Rank 1
answered on 27 Aug 2010, 05:30 PM
I am now getting an error: there is no source code available for the current location.
Here is my xaml and refs.

xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
  xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
 xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
   xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    x:Class="Agreement.Agreements"
    xmlns:local="clr-namespace:Agreement"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
  
<telerikGridView:GridViewDataColumn  DataMemberBinding="{Binding BeginDate, Mode=TwoWay}" >
                            <telerikGridView:GridViewDataColumn.Header>
                                <StackPanel Orientation="Vertical">
                                    <!-- This display the wording Date under Begin.-->
                                    <TextBlock  Text="Begin" HorizontalAlignment="Left" />
                                    <TextBlock  Text="Date" HorizontalAlignment="Left" />
                                </StackPanel>
                            </telerikGridView:GridViewDataColumn.Header>
                            <telerikGridView:GridViewDataColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding BeginDate, Converter={StaticResource DateTimeConverter}, ConverterParameter=d}"/>
                                </DataTemplate>
                                  
                            </telerikGridView:GridViewDataColumn.CellTemplate>
                            <telerikGridView:GridViewDataColumn.CellEditTemplate>
                                <DataTemplate>
                                   <telerikInput:RadDatePicker x:Name="dtBeginDate"
                                   SelectableDateStart=" DateTime.Today"
                                   SelectableDateEnd=" DateTime.Today.AddDays(-30)">
                                     
                                   </telerikInput:RadDatePicker>
  
                                </DataTemplate>
                            </telerikGridView:GridViewDataColumn.CellEditTemplate>
  
                        </telerikGridView:GridViewDataColumn>
0
Accepted
Maya
Telerik team
answered on 30 Aug 2010, 09:56 AM
Hi Keith Stephens,

You cannot set the SelectableDateStart Property as "DateTime.Today" in xaml. What you can do is to expose a new custom property holding the information for the "start date" and "end date" as suggested here. For example:

public string SelectableDateStart
{
    get
    {
        return DateTime.Now.ToString(this.DateFormat);
    }
    set{}
}

You can bind it to the SelectableDateStart Property like follows:
<telerik:RadDateTimePicker SelectableDateStart="{Binding Source={StaticResource                             theTime},
                          Path=SelectableDateStart, Mode=OneWay}"
/>

I am sending you a sample project illustrating the proposed solution.


Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Keith Stephens
Top achievements
Rank 1
answered on 20 Sep 2010, 03:57 PM
Kind of; Just a little modification.

public string SelectableDateStart
       {
           get
           {
               return DateTime.Now.AddDays(-30).ToString(this.DateFormat);
           }
           set { }
       }
       public string SelectableDateEnd
       {
           get
           {
               return DateTime.Now.AddDays(90).ToString(this.DateFormat);
           }
           set { }
       }
Tags
GridView
Asked by
Keith Stephens
Top achievements
Rank 1
Answers by
Maya
Telerik team
Keith Stephens
Top achievements
Rank 1
Share this question
or