Intersoft Support Center

Customize Column Action

WebGrid also supports column action customization, for instances, adding new commands or displaying predefined filter menu similar to Windows Explorer.

In this topic, you will learn how to customize menu items in column action using OnColumnAction client side event.

To add new menu items in Column Action

  1. Bind WebGrid to ISLinqDataSource.
  2. Drag WebContextMenu control from Toolbox.
  3. Right click on WebContextMenu control and choose Visual Menu Builder
  4. Create menu items according to your needs, for example:


  5. Right-click on WebGrid control and choose Properties.
  6. In the Properties box, expand LayoutSettings.
  7. Set ShowColumnAction to True
  8. Put the following code in OnColumnAction client-side event to attach your custom column action.
    JavaScript Copy Code
    function OnColumnAction(controlId, column)
    {    
       if (column.Name == "ContactName") 
       {        
          var menu = ISGetObject("addItemMenu");        
          var grid = ISGetObject(controlId);        
          var eventLocation = menu.GetEventLocation();             
            
          eventLocation.X -= 8;        
          eventLocation.Y += 100;        
          menu.Show(eventLocation);        
          grid.ActionBoxShown = true;        
          return false;    
       }
    }
    

  9. Invoke OnColumnAction() method using OnColumnAction client side events in WebGrid.

    <ClientSideEvents OnColumnAction="OnColumnAction" />
    
  10. Run the project and it will look like following:



Previous Next