Can't clear value using contextMenu for dateTime column with timePicker editor

6 posts, 1 answers
  1. Shlomo Pleban
    Shlomo Pleban avatar
    5 posts
    Member since:
    Oct 2006

    Posted 06 Mar 2013 Link to this post

    Hi,

    I defined in two different grids two DateTimeColumn with timePicker editor . In the first column I have in the column ContextMenu the clear value option while in the other column I don't. 
    What I am trying to do is letting the user clear the time cell after he filled it by mistake (if he prefers to leave it empty).
    Let me know what I am doing wrong .... is it better way to do this ?
    // with clear value option
      var timeOnlyColumn = new GridViewDateTimeColumn
                {
                    HeaderText = "Time in",
                    Name = Data.cJobCardData.JobCardColumns.DateTimeIn,
                    FieldName = Data.cJobCardData.JobCardColumns.DateTimeIn,
                    Format = DateTimePickerFormat.Time,
                    EditorType = GridViewDateTimeEditorType.TimePicker,
                    FormatString = "{0: h:mm tt}",
                    TextAlignment = ContentAlignment.MiddleCenter,
                    Width = colWidth
                };
    // No clear value option
        var dateColumnIn = new GridViewDateTimeColumn
                {
                    HeaderText = "Date Time In",
                    Name = Data.cJobCardData.JobCardColumns.DateTimeIn,
                    FieldName = Data.cJobCardData.JobCardColumns.DateTimeIn,
                    Format = DateTimePickerFormat.Long,
                    EditorType = GridViewDateTimeEditorType.TimePicker,
                    FormatString = "{0: M/d/yyyy h:mm tt}",
                    TextAlignment = ContentAlignment.MiddleCenter,
                    Width = colWidth
                };
  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 11 Mar 2013 Link to this post

    Hi Shlomo,

    Thank you for writing.

    The column's setup does not have effect of the context menu options - check out the attached project. I would suggest that you revise your code for handlers of the ContextMenuOpening event and to make sure that you are not explicitly hiding the clear menu item.

    If you continue experiencing the same issue, please get back to me with a sample where it can be reproduced and I will look into it for you.

    I hope that you find this information useful.
     
    Regards,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. Amitay
    Amitay avatar
    1 posts
    Member since:
    Jan 2013

    Posted 13 Mar 2013 Link to this post

    Hi,

    Thanks for the response.

    I didn't change anything in the code , but know all works fine ...

    this is how I manage the context menu event.

    private void oeGrid_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
           {
               var isDateTime = ((RadGridView) sender).CurrentColumn as GridViewDateTimeColumn;
               for (int i = 0; i < e.ContextMenu.Items.Count; i++)
               {
                   if ((e.ContextMenu.Items[i].Text == "Copy") ||
                       (e.ContextMenu.Items[i].Text == "Paste") ||
                       (e.ContextMenu.Items[i].Text == "Pinned state") ||
                       ((e.ContextMenu.Items[i].Text == "Clear Value") && (isDateTime == null)) ||
                       (e.ContextMenu.Items[i].Text == "Conditional Formatting") ||
                       (e.ContextMenu.Items[i].Text == "Column Chooser") ||
                       (e.ContextMenu.Items[i].Text == "Hide Column")
                       )
                   {
                       // hide the Conditional Formatting option from the header row context menu
                       e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                       // hide the separator below the CF option
                       //e.ContextMenu.Items[i + 1].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                   }
               }
           }


    Do you suggest to change it ?
  4. Answer
    Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 18 Mar 2013 Link to this post

    Hello Amitay,

    This setup seems to be correct and I am not able to determine what cased this issue as I was not able to reproduce it.

    If you continue experiencing this issue, please get back to me with a sample where it can be reproduced and I will be glad to help you with it.
     

    Greetings,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  5. Shlomo Pleban
    Shlomo Pleban avatar
    5 posts
    Member since:
    Oct 2006

    Posted 16 Apr 2013 Link to this post

    The problem was that I was in a row edit mode, and then I couldn't clear the cell. 
    Once I moved to a new row , I could use the "Clear" option.
  6. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 19 Apr 2013 Link to this post

    Hi Shlomo,

    I am glad to hear that everything is now OK. Should you have any other questions, do not hesitate to contact us.
     

    Regards,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top