Batch Edit with DatePicker

5 posts, 0 answers
  1. Rich
    Rich avatar
    4 posts
    Member since:
    Dec 2014

    Posted 12 Nov 2015 Link to this post

    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?​

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 17 Nov 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rich
    Rich avatar
    4 posts
    Member since:
    Dec 2014

    Posted 17 Nov 2015 in reply to Konstantin Dikov Link to this post

    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.

  5. Augusto
    Augusto avatar
    5 posts
    Member since:
    Oct 2013

    Posted 22 Apr in reply to Konstantin Dikov Link to this post

    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);

  6. Augusto
    Augusto avatar
    5 posts
    Member since:
    Oct 2013

    Posted 22 Apr in reply to Augusto Link to this post

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

    }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017