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

[Solved] result from command

1 Answer 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carl
Top achievements
Rank 1
Carl asked on 29 Jun 2011, 02:03 PM
Hi,
        private void deleteOption_Click(object sender, RoutedEventArgs e)
    {
      
        var deleteCommand = RadGridViewCommands.Delete as RoutedUICommand;
        if (selectedItem == null)
        {
            return;
        }
        if (selectedItem.GetType() == typeof(RadGridView))
        {
            var rgv = (RadGridView)selectedItem;
            deleteCommand.Execute(null, rgv);
        }
    }
    private void cut_Click(object sender, RoutedEventArgs e)
    {
        deleteOption_Click(sender, e);
    }
 
   
private void _deletingOption(object sender, GridViewDeletingEventArgs e)
    {
        IEnumerable<object> items = e.Items;
        if (items == null)
        {
            return;
        }
        IEnumerator<object> optionEnum = items.GetEnumerator();
        optionEnum.MoveNext();
        RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.Option option = (RadControlsSilverlightApp5.com.tradestonesoftware.optionssheet.model.Option)optionEnum.Current;
        if (option.boms != null && option.boms.Count != 0)
        {
            Dispatcher.BeginInvoke(() =>
            {
                System.Windows.Browser.HtmlPage.Window.Alert("Row has children.  Delete child rows first.");
            });
            e.Cancel = true;
        }
        e.Handled = true;
    }
What is the best way to retrieve a result from a command?  For example, I want to know whether or not a row was deleted when I do the above.  When I do cutOption_Click I would like to know if the delete of the row actually happened.  Should I use
an instance variable?  Is the main class threadsafe? Or is their a way to pass in a parameter to the methods that can be inspected upon completion?

Thanks,

Carl

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 04 Jul 2011, 03:35 PM
Hi Carl,

 If you would like to receive a feedback for the result from a command, you will need to create your custom command that implements ICommand. It may use the inbuilt commands internally, but still you may add any custom additional logic that you need. 

I see that you execute a command manually by code on a button click. You would better use the command property of RadButton, or any other suitable control, like shown in this help article. Then you just need to bind the command's property to your custom command.

All the best,
Didie
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Carl
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or