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

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

5 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shlomo Pleban
Top achievements
Rank 1
Shlomo Pleban asked on 07 Mar 2013, 12:47 AM
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
            };

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 11 Mar 2013, 11:33 AM
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.
0
Amitay
Top achievements
Rank 1
answered on 13 Mar 2013, 09:14 PM
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 ?
0
Accepted
Stefan
Telerik team
answered on 18 Mar 2013, 09:14 AM
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.
0
Shlomo Pleban
Top achievements
Rank 1
answered on 16 Apr 2013, 06:03 PM
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.
0
Stefan
Telerik team
answered on 19 Apr 2013, 11:50 AM
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.
Tags
GridView
Asked by
Shlomo Pleban
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Amitay
Top achievements
Rank 1
Shlomo Pleban
Top achievements
Rank 1
Share this question
or