This Question is Answered

15 "helpful" answers available (3 pts)
3 Replies Last post: May 27, 2008 3:10 AM by varshuj

RecordGrid context menu

May 26, 2008 1:58 AM

Click to view varshuj's profile Level 3 varshuj 44 posts since
Mar 6, 2008

How to add custom context menus for recordgrid header and recordgrid body by suppressing the default context menus.

Thanks

Varsha

Click to view Duke's profile Curl Duke 154 posts since
Oct 17, 2007
1. Re: RecordGrid context menu May 26, 2008 9:35 AM
Maybe someone more familiar with RecordGrid will have a better idea, but you might have to work on the open source for RecordGrid to make your changes. If you look in the IDE Developer's Guide documentation, index entry "controls > open", it tells you about how to use the open source for controls that is available in your IDE installation directory at ide\gui\controls.

I do notice there is RecordGrid.filter-menu-proc which

"allows cell-by-cell customization of the filtering controls presented in a RecordGrid's context menu.

When set for a RecordGridCell in a StandardRecordGridUI, the proc will be called each time a context menu is created for that cell, and will receive an array of all the regular filter-related MenuItems and the context cell as its arguments. The array returned from this proc will then be placed into the filters section of the generated context menu."
Click to view friedger's profile MVP friedger 108 posts since
Jan 13, 2008
2. Re: RecordGrid context menu May 27, 2008 1:54 AM
in response to: Duke

You can overwrite context-menu-at in the StandardRecordGridUI or SkinnableRecordGridUI like below

It shows different context menus for header and first row and no context menu for all other rows.

Friedger



 
 
{define-class MyRecordGridUi {inherits StandardRecordGridUI}
  {method public open {context-menu-at
                          x:Distance,
                          y:Distance
                      }:#MenuPane
 
    let constant grid:RecordGrid = self.grid
    let constant dr:RecordView = grid.records
 
    let constant (cell:#RecordGridCell, rec:int, col:int) =
        {self.grid-objects-at x, y}
 
    let constant mp:MenuPane = {MenuPane}
 
    {if rec == -1 then
        {mp.add
            {MenuAction
                label = {hlmessage MyHeaderAction}
            }
        }
     elseif rec == 0 then
        {mp.add
            {MenuAction
                label = {hlmessage MyBodyAction for row 1}
            }
        }
    }
    {return mp}
  }
}
 
{RecordGrid ui-object = {MyRecordGridUi},
    record-source = {LocalRecordSet {RecordFields {RecordField "col1", domain = String}, {RecordField "col2", domain = String}},
                        {RecordData col1 = "A", col2 = "B"},
                        {RecordData col1 = "X", col2 = "Y"}
                    }
}
 
 


Click to view varshuj's profile Level 3 varshuj 44 posts since
Mar 6, 2008
3. Re: RecordGrid context menu May 27, 2008 3:10 AM
in response to: friedger

Thanks friedger for your valuable suggestion

  • Varsha