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

Batch Edit with DatePicker

4 Answers 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 12 Nov 2015, 09:58 PM

Is it possible to get a DatePicker as the editor when doing client-side batch editing? I've tried:

<telerik:GridDateTimeColumn DataField="FirstPaymentDate" PickerType="DatePicker" HeaderText="1st Pmt. Due" UniqueName="FirstPaymentDate" HeaderStyle-Width="100px" ItemStyle-Width="100px" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AllowSorting="false" />

 and

<telerik:GridTemplateColumn HeaderText="1st Pmt. Due" UniqueName="FirstPaymentDate" DataType="System.DateTime" HeaderStyle-Width="100px" ItemStyle-Width="100px" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AllowSorting="false"><br>                                <ItemTemplate><br>                                    <asp:Label runat="server" ID="date"Text='<%# Eval("FirstPaymentDate") %>'><br>                                    </asp:Label><br>                                </ItemTemplate><br>                                <EditItemTemplate><br>                                    <telerik:RadDateTimePicker ID="picker1" runat="server" DbSelectedDate='<%# Bind("date") %>'><br>                                    </telerik:RadDateTimePicker><br>                                </EditItemTemplate><br>                            </telerik:GridTemplateColumn>

 and in neither case do I get a DatePicker control when I click to enter edit mode.

I've searched extensively and haven't been able to find an example that does this. Is it possible? Can someone provide or point me to an example?​

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 17 Nov 2015, 11:11 AM
Hi Rich,

With the columns definition that you are using, the rendered editor should be a RadDatePicker and I am assuming that you are not seeing the calendar icon due to the fact that your column width is set to 100px and the default width of the editor is higher. If you set the Width to 200px for example you will notice that you will see correctly the calendar icon.

If you need to change the width of the editor with Batch Editing you could get reference to the editor on the server-side OnPreRender event of the grid (as demonstrated in our help article "Batch Editing Server-side API"):

Another option is to add the following code in your OnPreRender event, which will set the width of all editors to "100%":
GridTableView masterTable = (sender as RadGrid).MasterTableView;
foreach (GridColumn column in masterTable.RenderColumns)
{
    if ((column is IGridEditableColumn) && (column as IGridEditableColumn).IsEditable && masterTable.GetBatchColumnEditor(column.UniqueName) != null)
    {
        Control container = (masterTable.GetBatchColumnEditor(column.UniqueName) as IGridColumnEditor).ContainerControl;
        if (container != null && container.Controls.Count > 0)
        {
            (container.Controls[0] as WebControl).Width = Unit.Percentage(100);
        }
    }
}

Hope this helps.

Regards,
Konstantin Dikov
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Rich
Top achievements
Rank 1
answered on 18 Nov 2015, 12:12 AM

Thanks Konstantin.

Increasing the width solved my problem. I knew it was supposed to generate a default editor but couldn't figure out why it wasn't.

0
Augusto
Top achievements
Rank 1
answered on 22 Apr 2016, 04:56 PM

The solution to set with in edit mode "not using templates "  is:

for datetime column as:

<telerik:GridDateTimeColumn DataField="N_ENTRADA" HeaderText="Entrada" UniqueName="N_ENTRADA" Visible="true" ReadOnly="false" DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="118"> </telerik:GridDateTimeColumn>

Solution:
RadDatePicker fechaEntrada = (RGridNomina.MasterTableView.GetBatchColumnEditor("N_ENTRADA") as GridDateTimeColumnEditor).PickerControl;
            fechaEntrada.Width = Unit.Pixel(110);

 

For numeric column as :

<telerik:GridNumericColumn HeaderStyle-Width="100" ItemStyle-HorizontalAlign="Right" FooterStyle-HorizontalAlign="Right" DecimalDigits="2" Aggregate="Sum" FooterText=" " DataField="N_CONCEPTO01" HeaderText="Concepto_01"  UniqueName="N_CONCEPTO01"  Visible="false" ReadOnly="false"></telerik:GridNumericColumn>

 

Solution:

RadNumericTextBox unitsNumericTextBox = (RGridNomina.MasterTableView.GetBatchColumnEditor("N_CONCEPTO01") as GridNumericColumnEditor).NumericTextBox;
unitsNumericTextBox.Width = Unit.Pixel(80);

0
Augusto
Top achievements
Rank 1
answered on 22 Apr 2016, 04:57 PM

Should be into  protected void RGridXXX_PreRender(object sender, EventArgs e)
        {

}

Tags
Grid
Asked by
Rich
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Rich
Top achievements
Rank 1
Augusto
Top achievements
Rank 1
Share this question
or