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

[Solved] Nullable DatePicker

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daryl Shenner
Top achievements
Rank 1
Daryl Shenner asked on 30 Jan 2012, 07:22 AM
Hi,

I've a DatePicker column in my Grid to show blank value when user clicks the Edit Button(In Line Editing) where there is no value to the column is been binded

Whenever I click the edit button,i get the blank cell eventhough I have value to the cell. I'd like to display the value with DatePicker Control when it has otherwise blank cell with DatePicker Control.  Please help us



3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 31 Jan 2012, 11:09 AM
Hi Daryl,

Basically the DatePicker editor template should look like this.

@model DateTime?
 
@(Html.Telerik().DatePicker()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .HtmlAttributes(new { id = ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty) + "_wrapper" })       
)
I assume that the behavior you described is caused because you assign different name for your DatePicker.
If this is not the case please provide more details (code used for the different views/editors, model and the values passed by the controller).

Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Daryl Shenner
Top achievements
Rank 1
answered on 01 Feb 2012, 04:54 AM
Hi,

I Still don't find the solution. Here is my code

Editor Template: Date.cshtml
@model DateTime?          
@(Html.Telerik().DatePicker().Value(Model))

The Value that gets binded, 1/28/2012

My Model:

 [DataType(DataType.Date)]
public DateTime? DueDate { get; set; }

[DataType(DataType.Date)]
public DateTime? ReceivedDate { get; set; }
0
Petur Subev
Telerik team
answered on 01 Feb 2012, 12:40 PM
Hello Daryl,

Everything works fine on my side.
For your convenience I attached a sample project which implements the the desired behavior. Could you please check if I missed something ?

Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Daryl Shenner
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Daryl Shenner
Top achievements
Rank 1
Share this question
or