This is a migrated thread and some comments may be shown as answers.
DatePicker JQuery Reference Needed
2 Answers 35 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 07 Dec 2010, 10:12 AM
<%=Html.Telerik().DatePicker()
    .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
    .HtmlAttributes(
        new
            {
                id =ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty) +DateTime.Now.Millisecond
            })
.Value(Model > DateTime.MinValue ? Model : DateTime.Today)
.InputHtmlAttributes(new { style = "width: 110px" })
%>

<input value="7/12/2010" style="width: 110px;" name="StartDate" id="StartDate951-input" class="t-input" autocomplete="off">

I'm using Ajax binding with the Editor Template in an Telerik  MVC  Grid.
How do I get a JQuery reference to a DatePicker Control (in this example,called StartDate)  that is being edited?

The following code works fine, but I obviously don't know the actual id as this is dynamic based on template (millisecs) above
var date1 = $('#StartDate951').data("tDatePicker").value();

As Id of the DateTimePicker is auto-generated, I need something less direct and was wondering if there is a JQuery that can pick up the current rows StartDate value WITHOUT knowing the suffix (in this case 951)

The telerik grid bound column is :

columns.Bound(o => o.StartDate).Width(170).Format("{0:ddd, dd MMM yyyy}");

thanks



2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 07 Dec 2010, 03:35 PM
Hello Steve,

In order to find DatePicker component you can use StartsWith jQuery selector. Thus you will not depend on the suffix. Here is a code snippet which shows how to achieve this:
function onEdit(e) {
        $(e.form).find('[id^="ColumnName"][class*="t-datepicker"]')
    }
Wire OnEdit client event and search for the rendered DatePicker UI component there.

Kind regards,
Georgi Krustev
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
Steve
Top achievements
Rank 1
answered on 08 Dec 2010, 02:40 AM
Thanks Georgi, looks like that is exactly what I'm looking for...

Cheers
 
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or