8 Answers, 1 is accepted
Hi Jason, did you ever find an answer to this? I'm wondering the same about defaults for date fields.
Thanks,
dave
edit: It looks like in the demos they use a DatePicker, which does allow you to set default values. It'd be nice to have defaults for text fields, but this will work for me for dates...
edit again: Ok, so it looks like the DatePicker lets you set a global default -- e.g. all of the DatePickers in your application will default to today's date -- but I don't see how to set different defaults per field, as in your question. Telerik guys, is there a way to do this?
ROSCO
If you want to set default values for new records you should use the DefaultDataItem setting:
.Editable(editing => editing.DefaultDataItem(new SomeType { Property1 = "", Property2 = 20 }))Atanas Korchev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
That appears to be part of the MVC extensions, is it possible using webforms?
ROSCO
I am not sure what you mean. This forum is for Telerik Grid for ASP.NET MVC. Are you using the same component?
Regards,Atanas Korchev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
ROSCO
I am attaching a sample solution that illustrates what you are trying to achieve.
In my solution I am giving two options:
1) Define the dates in declaratively in the design page:
<telerik:GridTemplateColumn UniqueName="Date1" HeaderText="Date1"> <ItemTemplate> <asp:Label Text='<%# Eval("StartTime") %>' runat="server" /> </ItemTemplate> <EditItemTemplate> <telerik:RadDatePicker ID="picker1" MinDate="1900/1/1" runat="server" DbSelectedDate='<%# Bind("StartTime") %>' SelectedDate='<%# System.DateTime.Now.AddDays(2) %>' ></telerik:RadDatePicker> </EditItemTemplate></telerik:GridTemplateColumn>2) Or, if you need to make more complex manipulations to the dates you can modify them in the code behind(i have commented out this part in my solution)
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode == true) { (e.Item.FindControl("picker3") as RadDatePicker).SelectedDate = DateTime.Now; (e.Item.FindControl("picker2") as RadDatePicker).SelectedDate = DateTime.Now.AddDays(1); (e.Item.FindControl("picker1") as RadDatePicker).SelectedDate = DateTime.Now.AddDays(2); }}I am also attaching the dummy database table that I used for this example.
Kind regards,
Genti
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
ROSCO