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

Add datepicker to column

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 02 Sep 2013, 02:50 PM
Hi,
I have 3 columns in this grid that deal with date and I would like to add a datetimePicker on their side.
I have tried without success for a sometime.
Here is my code. Could you please suggest what should I change to make the date picker showing up.
Thanks a lot

<telerik:RadGrid ID="RadGrid2" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" Culture="it-IT" DataSourceID="SqlDataSource1" GridLines="None" OnItemDataBound="RadGrid2_ItemDataBound" EnableHeaderContextMenu="True">
            <ClientSettings>
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="Id" DataSourceID="SqlDataSource1" IsFilterItemExpanded="False" ShowHeader="True">
                <CommandItemSettings ShowCancelChangesButton="True" ShowExportToPdfButton="True" ShowSaveChangesButton="True" ShowExportToExcelButton="True" />
                <Columns>
                    <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" FilterControlAltText="Filter Id column" HeaderText="Id" ReadOnly="True" SortExpression="Id" UniqueName="Id">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Tipo" FilterControlAltText="Filter Tipo column" HeaderText="Tipo" SortExpression="Tipo" UniqueName="Tipo">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Scadenza" DataType="System.DateTime" FilterControlAltText="Filter Scadenza column" HeaderText="Scadenza" SortExpression="Scadenza" UniqueName="Scadenza" DataFormatString="{0:dd/MM/yyyy}">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Periodo_Inizio" DataType="System.DateTime" FilterControlAltText="Filter Periodo_Inizio column" HeaderText="Periodo_Inizio" SortExpression="Periodo_Inizio" UniqueName="Periodo_Inizio" DataFormatString="{0:dd/MM/yyyy}">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Periodo_fine" DataType="System.DateTime" FilterControlAltText="Filter Periodo_fine column" HeaderText="Periodo_fine" SortExpression="Periodo_fine" UniqueName="Periodo_fine" DataFormatString="{0:dd/MM/yyyy}">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridAttachmentColumn FileName="attachment" FilterControlAltText="Filter AttachmentColumn column" UniqueName="AttachmentColumn" HeaderText="Carica allegati">
                    </telerik:GridAttachmentColumn>
                    <telerik:GridBoundColumn DataField="Note" FilterControlAltText="Filter Note column" HeaderText="Note" SortExpression="Note" UniqueName="Note">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                </Columns>
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
            </MasterTableView>
        </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 03 Sep 2013, 03:10 AM
Hi Felice,

In order to obtain a datepicker you must use a GridDateTimeColumn.When in browser mode, GridDateTimeColumn looks and behaves like a standard GridBoundColumn. When in edit mode, however, it displays a RadDateInput, RadDatePicker, RadTimePicker, or RadDateTimePicker control. This column type is for date and time values. Its DataField property must identify a field with a valid data type (DateTime).

ASPX:
<telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="GridDateTimeColumn" UniqueName="OrderDate" PickerType="DatePicker" />

Thanks,
Princy
0
Felice
Top achievements
Rank 1
answered on 03 Sep 2013, 07:37 AM
Thanks. I managed it. It works now.
Tags
Grid
Asked by
Felice
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Felice
Top achievements
Rank 1
Share this question
or