Print Page | Close Window

GridViewContext.RowDoubleClickCommandName

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=545
Printed Date: 11-Jun-2026 at 12:22pm


Topic: GridViewContext.RowDoubleClickCommandName
Posted By: orcities
Subject: GridViewContext.RowDoubleClickCommandName
Date Posted: 13-Nov-2007 at 2:32pm
I am trying to get the double click feature to work on a grid.
In the page controller where I set the ViewContext for the grid I have set the RowDoubleClickCommandName of the GridContext to EditNames.Edit. Hoping that it will run the edit command for that Grid but it doesn't. What am I doing wrong?
 
Code Excerpt (From SearchSummaryDetailPageController)
 

private void AddSearchResultsViewContext()

{

      // Create and add a new GridViewContext for the master grid

      GridViewContext searchResultsViewContext =

                            GridViewContext.AddNew(WorkItem, SearcherViewController.SearchResultsViewId);

 

      searchResultsViewContext.BeforeLeaveRowHandler = MasterGridBeforeLeaveRowHandler;

 

      searchResultsViewContext.RowDoubleClickCommandName =

CommandNames.Edit;
      //Have also tried
      //searchResultsViewContext.RowDoubleClickCommandName =searchResultsViewContext.MakeViewSpecifiedId(CommandNames.Edit);

}



Replies:
Posted By: Bill Jensen
Date Posted: 13-Nov-2007 at 3:19pm
Hi Dan,
You'll need a unique command name, so the second form:
 
searchResultsViewContext.RowDoubleClickCommandName =searchResultsViewContext.MakeViewSpecifiedId(CommandNames.Edit);
 
is what you want.
 
The next question is "What do you want to happen when the command is fired?"  You'll need to attach a handler to the command like this:

string commandName = viewContext.MakeViewSpecificId(CommandNames.Edit);

Command cmd = WorkItem.Commands.Get(commandName);

// Attach command handler

cmd.ExecuteAction += new EventHandler(cmd_ExecuteAction);
----------------------------------
 
void cmd_ExecuteAction(object sender, EventArgs e)

{

// Perform edit processing here

}

Bill J.



Posted By: Bill Jensen
Date Posted: 14-Dec-2007 at 4:37pm
I missed an important point. 
 
CAB provides a declarative syntax for specifying a command handler:

[CommandHandler(commandName)]

void
cmd_ExecuteAction(object sender, EventArgs e)

{

// Perform edit processing here

}

That way you don't have to fish the command out of the WorkItem and attach the handler yourself.

Sorry,
Bill J.


Posted By: orcities
Date Posted: 18-Dec-2007 at 8:45am
Is there a specific place this should go?


Posted By: Bill Jensen
Date Posted: 20-Dec-2007 at 12:52pm
On the handler method for the command, where I showed it in my example.
 
Bill



Print Page | Close Window