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

Add event handlers on editors

2 Answers 35 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Lorenzo
Top achievements
Rank 1
Lorenzo asked on 21 May 2014, 11:16 AM
Hello,


I am looking for a way to control when a cell is edited in a GanttViewTextViewCellElement. If certain conditions are met, the old value should be reset. How and when should I add handlers?

I am thinking on the editors of each cellElement but I dont know how to reach them in a way like in Gridview where the CellBeginEdit event is handy for it.

Thanks,
Lorenzo.

2 Answers, 1 is accepted

Sort by
0
Lorenzo
Top achievements
Rank 1
answered on 21 May 2014, 03:18 PM
Hello again.

I forgot to say that I haven't found an event that appears in the documentation for GanttView controls: "EditorRequired". I suppose that it wold be a nice place to attach an event handler.

Regards,
Lorenzo
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 May 2014, 06:47 AM
Hello Lorenzo,

Thank you for writing.

It is possible to perform validation of the editor's valueбъ subscribing to the ValueChanging event for the respective editor. Here is a sample code snippet, demonstrating how to use the GanttViewElement.EditorInitialized event and subscribe to the GanttViewDateTimeEditor.ValueChanging event, which can be canceled when the new value is not valid:
private void GanttViewElement_EditorInitialized(object sender, GanttViewItemEditorInitializedEventArgs e)
{
    GanttViewDateTimeEditor dtEditor = e.Editor as GanttViewDateTimeEditor;
    if (dtEditor != null)
    {
        dtEditor.ValueChanging-=dtEditor_ValueChanging;
        dtEditor.ValueChanging+=dtEditor_ValueChanging;
    }
}
 
private void dtEditor_ValueChanging(object sender, ValueChangingEventArgs e)
{
    if ("New value is not valid")
    {
           e.Cancel = true;
    }       
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GanttView
Asked by
Lorenzo
Top achievements
Rank 1
Answers by
Lorenzo
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or