Dialogs and menus
FastGrid documentation
To display FastGrid as dialog, set
Place.Area in the input data.
To display FastGrid deriving predefined dialog like Menu or Calendar, set
Dialog attribute in input data.
To display popup dialog for FastGrid cell use actions or API methods like
ShowMenu,
ShowList or
ShowCalendar.
Example shows simple dialog derived from "Menu":
FGrid.FastGrid({ Dialog:"Menu", Script: { Items:"|Item 1|Item 2|Item 3" }, Place: { Area:[300,200] }, Events: { OnAccept:function(G,val){ alert("Chosen "+val); } } });
Example shows simple dialog derived from "Calendar":
FGrid.FastGrid({ Dialog:"Calendar", Script: { Dates:"1/1/2020~1/7/2020", Range:1 }, Place: { Area:[300,400] }, Events: { OnAccept:function(G,val){ alert("Selected dates "+G.DateToString(val,"M/d/yyyy",2)); } } });
Grid string
Dialog
Specifies predefined dialog from
Dialogs to derive this FastGrid from.
If set, FastGrid defines its data according to the this
Dialog specification, usually in
Script tag. For example for "
Menu" dialog defines especially Script.
Items.
Don't confuse with API variable Dialog that contains actually displayed popup dialog for the grid.
Grid Dialog[]
Dialogs
[...]
FastGrid root tag with all predefined dialogs, menus, calendar, etc. It contains named array of all the Dialog objects their names can be used in
D when showing dialog.
Dialog string
D
[...]
Default dialog definition used for the dialog. The default dialog defines the attributes that the dialog has not set.
Predefined defaults in
Defaults.js:
Base | Base default for all dialogs, menus, calendar, etc., it is not set explicitly. |
Menu | Default for all menus with items, use also for custom menus (defined in Menu.js) |
Popup | Default for normal menu by Menu attribute or by ShowMenu |
List | Default for List menu |
Suggest | Default for Suggest menu. |
FormulaSuggest | Default for Suggest formula function menu. |
Filter | Default for menu with Filter operators |
Settings | Default for menu with FastGrid settings |
Calendar | Default for calendar (datepicker) dialog (defined in Calendar.js) |
FGrid any
DialogsTag
Attribute of global FGrid object. It is shared among all grids on page.
HTML tag where to place FastGrid dialogs and messages. It is also used as temporary parent of tags for other purposes in FastGrid, e.g. for tag to measure fonts.
This tag must be visible (it and all its parents must not have set display:none or visibility:hidden).
If this tag or some its parent has position:absolute, there must be set DialogsFixed = 1.
It can be HTMLElement object or string as some DOM tag id.
It can be
1 to use the first rendered FastGrid tag as the parent.
Remember, if this grid tag is hidden or removed, dialogs of all other grids will be hidden too!
It can be set also in the first FastGrid input data in FGrid, like
FGrid: { DialogsTag: "MyParent" }
FGrid bool
DialogsFixed
[0]
Attribute of global FGrid object. It is shared among all grids on page.
If set, it does not scroll the FastGrid dialogs with HTML body, displays them with
position:fixed.
FGrid int
DialogsZIndex
[1000]
Attribute of global FGrid object. It is shared among all grids on page.
z-index of the dialogs tag. Set higher value if the dialogs are behind another tag in page.
Grid method Grid
ShowDialog
(Row row, Col col, any dialog)
Shows given
dialog for given cell. If
row and
col are null, the dialog is shown centered inside the whole grid.
The
dialog can be the FastGrid JSON data or string as id of the predefined dialog from
Dialogs.
Returns created grid object or null for error.
For example
grid.ShowDialog(null,null,"Settings") shows modal dialog with grid configuration.
API event object
OnGetMenuCustom
(Grid grid, string itemid, string menuname)
Called when showing predefined menu (Settings, Print, Export, Copy, Paste, Group, Search, FilterAction, ClearSort, Pivot) for custom item that do not exist in the default implementation.
Return object of the menu item. This object should have set at least
id to the
itemid,
Text and
Value attributes.
itemid is the id of the custom item,
menuname is the menu name like "Settings" or "Search".
API event void
OnSetMenuCustom
(Grid grid, string itemid, any itemvalue, string menuname)
Called when accepting predefined menu (Settings, Print, Export, Copy, Paste, Group, Search, FilterAction, ClearSort, Pivot) for custom item that do not exist in the default implementation.
itemvalue is the item
Value attribute value,
itemid is the id of the custom item,
menuname is the menu name like "Settings" or "Search".
Dialog Place
Position of the FastGrid if shown as dialog, required attribute is
Area.
Grid Place
Place
Settings for position of the FastGrid if shown as dialog.
Place any
Area
Area where the dialog is aligned to. It can be:
1) array of 4 integers as
[left,top,width,height] as absolute position of the area.
2)
HTML tag object its size and position will be used.
3)
string as id of the HTML tag object its size and position will be used.
Place int
Align
[0]
Horizontal align of the dialog:
0 - left inside,
1 - right inside,
2 - center inside,
3 - left outside,
4 - right outside.
Place int
VertAlign
[4]
Vertical align of the dialog:
0 - top inside,
1 - bottom inside,
2 - center inside,
3 - above outside,
4 - below outside.
Place int
Shift
[1]
Shifts dialog to Area for Align / VertAlign = 3 or 4, in pixels. To overlay the dialog and Area by border or to move dialog under mouse cursor.
Place int
ShiftX
[0]
Shifts dialog right by this amount of pixels (left if negative).
Place int
ShiftY
[0]
Shifts dialog down by this amount of pixels (up if negative).
Place flags
Update
["Align,VertAlign,Horz,Width,Height,Abs"]
How the dialog will be updated if it goes outside
Space.
Flags are case insensitive. The updates are done in the order the flags are present in the value.
Align - horizontal re-align, changes edge of the
Align, values
0 <=>
1 and
3 <=>
4.
VertAlign - vertical re-align, changes edge of the
VertAlign, values
0 <=>
1 and
3 <=>
4.
Horz - moves the dialog horizontally.
Vert - moves the dialog vertically.
Width - shrinks the dialog width.
Height - shrinks the dialog height.
Abs - shows the dialog in top or left corner of the window always as absolute.
Widen - resizes the dialog width if it is narower than
Area.
Place int[]
Space
Area for
Update as
[left,top,width,height]. If not set, [0,0,window_width,window_height] is used.
Place int
Min
[5]
Minimal reserved space between Space edge and dialog for
Update.
Place bool
Header
[0]
If set, marks the
Area with header. Only for
VertAlign =
3 or
4 and
Align = 0, 1, 2.
If the dialog is narower than Area, it resizes the dialog width to the Area width like
Update&16.
If the dialog is wider than Area, it resizes the marked header and fills the rest by
HeaderColor if set.
Place string / string[]
HeaderColor
Color used to fill the rest of
Header when the dialog is wider than the Area.
Place string
Shadow
CSS box-shadow around the dialog without header.
Place string
HeaderShadow
CSS box-shadow around the dialog with header.
Place int
Animate
[200]
If and how long (in milliseconds) animates the showing and hiding the dialog.
Place bool
Fixed
[0]
If set, displays the dialog with position:fixed and it is not scrolled by window scrollbars.
Place bool
Mouse
[0]
If set, displays the dialog on mouse position regardless on the
Area.
Place number
MouseX
Absolute X position of the mouse cursor on page. It can be set if the dialog is displayed under mouse cursor to hover it on start without mouse move.
Place number
MouseY
Absolute Y position of the mouse cursor on page. It can be set if the dialog is displayed under mouse cursor to hover it on start without mouse move.
Place any
Tag
Tag where to render the grid. It can be HTMLElement object or string as tag id. If not set, document.body is used as the parent tag for the dialog.
If not set
Area and grid has not set tag by
FastGrid() parameter, it is used as parent tag for statically rendered grid (not as dialog).
Place bool
Modal
If set, disables
Parent grid on the dialog show and enables it on the dialog close.
Dialog API
API methods and properties that can be used in all FastGrid dialog implementations like Menu and Calendar and in all custom dialogs.
Grid method bool
Accept
(any value, any onaccept = null, int level = 0, bool filteroff = null)
If the grid is shown as dialog, the method accepts the dialog with the
value and closes the dialog and clears the grid.
It sets the
value to value of the
Parent grid cell the dialog was shown for.
If set
onaccept, it calls this
OnAccept event handler. It can be string as FastGrid action or direct JavaScript function. If the
onaccept returns true, the function does not do anything else.
If set
level and the dialog is submenu, it modifies farther
Parent, e.g. for
level = 1 it modifies Parent.Parent, for 2 Parent.Parent.Parent. If the
level is too high, it modifies the farthest Parent.
If set
filteroff and the dialog is shown Parent grid Filter cell, it clears the filter operator. If set to
0, it does not test
value against
FilterOff.
API event any
OnAccept
(Grid grid, any value, Grid parent, Row parentrow, Col parentcol, Grid dialog)
Called before the dialog is accepted when the grid is shown as dialog.
grid is the accepted dialog grid,
value is the value the dialog accepted and will save to the parent cell.
If called from click to custom Menu button defined in
Buttons, the
value is the clicked button id.
If the
value is the clicked button id, the actual values can be got by
GetValues as object or by
Script.Values as string.
parent is parent grid that shows the dialog, the
parentrow,
parentcol is the cell for that the dialog is shown and that accepts the
value.
dialog is the dialog the accepted dialog item belongs to, it can differ from
grid when the
dialog is submenu.
The event is not called when the menu item has defined OnAccept event that returned true.
Return
true to not accept the
value and continue the dialog.
Return
false to close the menu without accepting the
value.
Return
null to accept the
value.
Return
number or
string to change the
value and accept it.
Actions
Close
(int target = 0, bool force = 0)
OnEsc
If the grid is shown as dialog, the action closes the dialog and clears its grid.
If set
force, it closes the dialog even if the
OnClose returns true.
Grid method bool
Close
(bool force = 0)
If the grid is shown as dialog, the method closes the dialog and clears its grid.
If set
force, it closes the dialog even if the
OnClose returns true.
Returns true if the dialog was closed. Returns false if the dialog is still opened.
API event bool
OnClose
(Grid grid, any value, Grid parent, Row parentrow, Col parentcol, Grid dialog)
Called after the dialog is accepted when the grid is shown as dialog.
grid is the accepted dialog grid,
value is the value the dialog accepted and will save to the parent cell.
parent is parent grid that shows the dialog, the
parentrow,
parentcol is the cell for that the dialog is shown and that accepts the
value.
dialog is the dialog the accepted dialog item belongs to, it can differ from
grid when the
dialog is submenu.
Return true to not close the dialog.
Grid variable Grid
Dialog
Actually shown dialog, if any. grid.Dialog.Parent == grid.
Don't confuse with grid attribute Dialog that specifies dialog to inherit the grid from.
Grid variable Grid
Parent
If this grid is a dialog, the Parent points to the grid that shows the dialog. grid.Parent.Dialog == grid.
For normal grids it is null.
Grid method object[]
GetParentCell
( )
Returns cell from
Parent grid this dialog is shown for. If the grid is not showns as dialog with Parent cell, returns null.
Returns JavaScript array as [row,col].
Grid method void
UpdateAsDialog
(bits type = 0)
Updates position of the grid shown as dialog according to the
Place Update. Call it after change in the dialog grid done by API.
type&
1 - if set, recalculates auto with of all visible columns in the grid.
It calls Paint() !
Menu definition in Script
Defining menu in Script tag. Menu is defined in file
Menu.js
Settings are available for all FastGrid menus like List, Suggest, Menu and any custom menus derived from Menu.
To preset some attribute in default menu in grid, set it like
Dialogs: { Menu: { Script: { Html:1 } } }
Grid Script
Script
Script tag is universal tag for defining parameters and methods of FastGrid shown as dialog.
Script Item[]
Items
Array of individual menu items.
It can be also one string, with comma separated menu item ids.
If the item is not an objects, it is take as:
null or
"" item is shown as empty cell {
Empty:
1 },
"-" is shown as {
Separator:
7 },
"-1-" to
"-8-" is shown as {
Separator:
1-
8 }.
"-0-xxx" is shown as item {
id: 'xxx' }, just to display special item ids starting by -
"-1-xxx" to
"-3-xxx" is shown as {
Caption:
1-
3,
Columns:
0,
id: 'xxx' },
"-5-xxx" to
"-7-xxx" is shown as {
Caption:
1-
3,
Columns:
0,
Empty:
1,
id: 'xxx' } without default
Item settings.
"*FilterOff" is shown as { FilterOff:1 },
string or
number is shown as item {
id: 'xxx' }.
Items can be read also from default menu D or generated in OnLoaded, but if the main Items is empty, the submenu or popup list can be disabled.
In this case define void Items as Items:[""].
Script Item
Item
Default item for all menu items in the
Items. All null values in the items are set by values defined in the
Item.
Item string / int
id
Menu item unique identification. It can be used as
Text or
Value if they are not set.
Item string
Text
Displayed text in the menu item. If not set, the
id is shown.
Item string
Value
Menu item value that is returned on the item click or as Bool / List / Edit / Menu item value.
Item int
Bool
If set, it shows checkbox. If set to
0, it ignores
Range and shows normal item,
1 shows checkbox on side set by
BoolAlign,
2 shows the checkbox on left,
3 shows checkbox on right.
If set 3. bit &
4, it permits three states of the checkbox, sets
BoolCycle to
2.
It cannot be set with Edit / List / Menu.
Item int
Edit
The item displays
Value right to the
Text in edit box and permits editing the Value.
If set to
1 specifies single line editbox.
If set to
2 or more, specifies number of lines in multiline editing and accepts enters (with ctrl/alt).
It cannot be set with Bool, but it can be set with List or Menu.
Item any
List
The item displays
Value right to the
Text in select box and permits selecting the Value from popup menu.
It can be set to standard JSON Menu like
ListMenu.
It cannot be set with Bool and Menu, but it can be set with Edit.
Item any
Menu
The item can display
Value right to the
Text without box and permits selecting the Value from submenu menu displayed left or right to the parent item.
It can be set to standard JSON Menu like
ListMenu.
It cannot be set with Bool and List, but it can be set with Edit.
Item bool
Range
If set with
Menu, it sets
Range to the popup list / menu.
Item int
L
[0]
Menu item level for auto generating submenus with the same settings as parent menu.
If the item
L is higher than previous item
L, this item is moved to the previous item
Menu. It it possible to create more levels of nesting.
If the item is not defined as object (for empty and separator items), it is moved to the previous item
Menu if next item has higher
L.
Use to split large menus with the same meaning items to submenus.
Item int
Width
Width of the
Value for Edit / List / Menu items in pixels. If not set, it is read from
ValueWidth or it is calculated according to the content size on start.
Item int
Align
Horizontal alignment of the
Value (for Edit / List / Menu) or for
Text (Bool) and default
Align for Menu / List menu items.
0 - left,
1 - right,
2 - center.
Item bool
BoolAlign
[1]
Side where to display checkbox in Bool==1 / Range==1.
0 - left,
1 - right.
Item string
Icon
Icon(s) that will be added to LeftIcons / RightIcons / TextIcons (according to the
IconAlign).
Item int
IconAlign
Horizontal alignment of the
Icon.
0 - left,
1 - right,
2 - center.
Item int
Columns
This and next items will be displayed in this number of columns. Until next item with Columns set.
If set to
0, this item only will have 1 column and next items will continue in previously set columns.
Item any
A
FastGrid cell attributes set to the item cell. It can be object with the attributes like
A:{ Color:"yellow" } or id of default cell in DefCells.
Item any
AV
FastGrid cell attributes set to the item cell value or icon for
List /
Menu /
Edit cell. It can be object with the attributes like
AV:{ Color:"yellow" } or id of default cell in DefCells.
Item int
Caption
If set, shows special inactive header item.
It can be set to
1 - in inverse style,
2 - in normal style,
3 - in plain style.
If set also
Bool, it displays active item with checkbox that controls all next
Bool items till next
Caption or
Separator.
Item bool
Empty
If set, shows special inactive empty item.
Item int
Separator
If set to
1 or
2, shows bottom border in the item. It can be used in any item.
1 has dark color,
2 has light color.
If set to
3 or
4, shows top border in the item. It can be used in any item.
3 has dark color,
4 has light color.
If set to
5 or
6, shows special inactive narrow item with horizontal line. In columns it shows the separator item with standard height to preserve the columns layout.
5 has dark color,
6 has light color and is narrower.
If set to
7 or
8, shows special inactive narrow item with horizontal line. In columns it shows the separator in the whole row and splits the items to columns above and below, like setting
Columns =
0.
7 has dark color,
8 has light color and is narrower.
Item bool
FilterOff
If set, shows special item to clear filter in the
Parent grid filter cell.
Item bool
NoClear
If set for
Bool, it does not change value on Clear button click.
Item int
Disabled
If set, the menu item is disabled and completely inactive. If set to
2, it also marks the item as semi transparent.
Item int
Height
Height of the menu item in pixels. If there are more items in columns, maximal Height is used.
Item int
PaddingTop
Top padding in the menu item in pixels. If there are more items in columns, maximal PaddingTop is used.
Item int
PaddingBottom
Bottom padding in the menu item in pixels. If there are more items in columns, maximal PaddingBottom is used.
Item string
Hint
Placeholder attribute, the Hint HTML value is shown on empty
Edit item.
Item string
Type
["Auto"]
Cell
Type for
Edit,
List and
Menu item.
Script any
Value
Initial value(s) for the menu according to the
ValueType.
Script int
ValueType
[1/5]
Type of
Value, especially for save by Ok button.
By default is
1 if Value is string or array otherwise it is
5.
0 - single value, menu item with this id is focused on start.
1 - string separated by
ValueSeparator as array of
Bool item ids, for
Range.
2 - array of
Bool item ids, for
Range.
3 - JSON string with List, Edit, Menu and Bool items as id: Value.
4 - JSON object with List, Edit, Menu and Bool items as id: Value.
5 - JSON string difference, the same as
3, but saves only items with different Value than the initial Value.
6 - JSON object difference, the same as
4, but saves only items with different Value than the initial Value.
Script string
Focus
If set to item id, focuses this item on start, use when the
Value contains more values for
ValueType > 0.
If set to
1, focuses first item if no item id corresponds to
Value.
Script bool
Range
If set, sets
Bool =
1 to all normal items without Bool / Menu / List / Edit / Caption / Empty / FilterOff / Separator(>=5).
Script bool
AutoSave
If set, automatically updates
Parent cell after any change in this menu or submenu.
Script int
Html
[1]
If set to
1, all menu item texts (
Text) can show html.
If set to
2, also all menu item values (
Value) can show html.
Script int
ValueWidth
Default width of the
Value for Edit / List items in pixels.
Script int
MenuValueWidth
Default width of the
Value for Menu items in pixels.
Script bool
ClickWhole
[1]
If set, the Bool / Edit / List / Menu are active as whole item. If not set, there is active only the checkbox / editbox / selectbox / menu button.
Script int
Level
[1000]
Menu level if it is shown as submenu.
0 - saves result to the
Parent,
1 - saves result to the Parent
.Parent,
2 - saves result to the Parent
.Parent
.Parent, etc.
If the Level is higher than last Parent, it saves to the last Parent.
Script bool
LevelBase
[0 / 1]
If set, the menu is never closed according to submenu
Level.
Default value is
0 for dialogs derived from
Menu /
Submenu and
1 for all other dialogs and popup grids.
Script string[]
Buttons
["" / "Ok,Clear"]
Which buttons will be shown on bottom toolbar, it can be comma separated string or array of the button ids. It controls also the button order.
Available buttons: "
Ok" - save changes and close menu, "
Cancel" - close menu without saving changes, "
Clear" - set on / off all
Bool items.
It is possible to add any custom button XXX, the button text will be "$TextXXX" and
OnAccept event will be called with "XXX" as the second parameter.
Default is "" for
Range = 0 and "Ok,Clear" for Range > 0.
Script int
ButtonsAlign
[2]
Horizontal alignment of the buttons,
0 - left,
1 - right,
2 - center.
Script string
Caption
Menu caption shown on the menu top.
Script int
Align
Horizontal alignment of all the
Value (for Edit / List / Menu) and for
Text (other items) and default
Align for Menu / List menus.
0 - left,
1 - right,
2 - center.
Script int
Columns
Initial value for
Columns, set to the first applicable item.
Script bool
ColumnsVert
[1]
If set, the items in columns are ordered vertically and not horizontally. It can slow down very large menus with columns.
Script int
ColumnsWidth
[1]
If set, all the columns have the same width - increases the narrow columns.
If set >
1, it is maximal width in pixels the narrow columns can be resized to.
Script bool
HideDisabled
If set, hides all items with
Disabled set instead of displaying the inactive and grayed.
Only if the item is not placed in
Columns.
Script method object[]
GetCell
(Grid grid, string id)
Returns FastGrid menu cell(s) for given menu item. It returns [row,col,textcol].
For menu items Edit, List and Menu is the
textcol the cell with Text and
col the cell with Value.
For other items is the
col the menu item cell and
textcol can be ingored.
It can be called from the menu events like
OnAccept or
OnSetValue.
Script method any
GetValue
(Grid grid, string id)
Returns value of given menu item. It can be called from the menu events like
OnAccept.
Script method bool
SetValue
(Grid grid, string id, any value)
Sets
value to given menu item. It can be called from the menu events like
OnSetValue to change other item value.
Returns true if the value was changed, false if the
value is the same as the cell value (no change was done) and null for error.
Script method object
GetValues
(Grid grid, bits type = 0)
Returns values of all menu items. For
type&
1 =
0 returns object with values by menu item ids. For
type&
1 =
1 returns array of items as [id,value,item].
If set
type&
2, it does not return disabled items.
If set
type&
4, it does not return unchanged items.
It can be called from the menu events like
OnAccept.
Script method void
Disable
(Grid grid, string id, bool disable)
Disables (
disable =
1) or enables (
disable =
0) given menu item cell.
It can be called from the menu events like
OnAccept or
OnSetValue.
Grid method any
OnSetValue
(Grid grid, Row row, Col col, any value, int changes)
Standard FastGrid event called before changing raw value of any cell, including Toolbar cells.
value is value to be set to the cell value. Return
value or new value to change it.
Returning
null is the same as returning
value. To return null value return global constant
FGrid.Null.
To cancel setting the value return global constant
FGrid.Cancel.
To get menu item id here call grid.GetAttr(row,col,"id").
Cell menu
Any cell popup menu, used also by
List and
Suggest.
The menu defines new FastGrid that contains the menu items, checkboxes, buttons, etc.
Menu JSON definition defines its parameters in
Script tag, especially items in
Script.Items. The menu position is defined in
Place tag.
The JSON menu can contain also the same tags as the FastGrid JSON like Cfg or Colors.
Unlike FastGrid definition it can contain
D attribute with name of default menu used for this menu.
Action menu shown by default on right click to cell. It can be:
a) | simple list with actions | "|text1|action1|text2|action2|text3|action3" or ["text1","action1","text2","action2,"text3","action3"] |
The first character separated string or JSON array as simple list of menu items with pairs of the texts and actions.
|
b) | menu grid rows |
[{Value:text1,OnAccept:action1,Attr11:...,Attr12:...},
{Value:text2,OnAccept:action2,Attr21:...,Attr22:...},...] |
The Value (text) is menu item text, the OnAccept is action code run on click to the menu item.
Attributes Attr are standard FastGrid row attributes to be applied to the menu item row. |
c) | full menu grid | { D:"...", Place:{...}, Tag1:..., Tag2:..., ..., Script:{ Items:[...], ... } } | Standard FastGrid Menu object with Tags like Cfg or Format. The Items contains the same the array as in the point b). |
The default menu default (
D attribute) for Menu is "
Popup".
The
action is JavaScript code run on click to the menu item.
This code can use variables
Grid,
Row,
Col,
Event and
Value as clicked menu item id.
It can call all grid actions without "Action" prefix and Grid object, like
"AddRow()" is the same as
"Grid.ActionAddRow()".
It returns
true if action succeeded or
false if failed.
The code need not contain
return statement if the whole code is an expression returning value.
Like
"AddRow()" vs.
"var ret = AddRow(); return ret;"
The action code can call also any FastGrid methods as methods of the
Grid object and also all global JavaScript functions.
If the action is empty, after item click it sets to the cell value the item id or index.
If the
action code contains test for
Grid.Test, it is called also on menu display to test if the action is available for the cell and actual state to show or hide its menu item.
In this case there is set
Grid.Test =
1 in time of testing call.
For example
Menu:"|Delete|Grid.Test ? !Grid.IsDeleted(Row) : Grid.Delete(Row)|Hide|HideRow()"
The action code that calls only FastGrid action(s) and not any API method or custom function is also called to test the menu item visibility, because the FastGrid actions automatically check the Grid.Test.
Or the
action can be direct JavaScript function as
function(Grid,Row,Col,Event,Value){...}, but its code cannot call actions without Grid keyword, must use return statement to return value and is not used for tests.
Item void
OnAccept
(Grid Grid, Row Row, Col Col, Event Event, any Value)
JSON event handler (JavaScript code in string or JavaScript function) assigned to Menu item.
Called when menu item is accepted, usually by click or Enter.
Row,
Col is the
Grid cell the menu belongs to,
Grid is the source grid, not the menu grid.
Event is the FastGrid event object,
Value is special parameter that contains the id of the menu cell.
Actions
ShowMenu
(int target = 0, Menu menu = null, string def = "Popup" / "Tool", bits type = 0)
OnRightClickAny, various button click events
Shows menu for actual or focused cell.
menu is Menu object to show, its format is the same
Menu. If not set, the
Menu is used.
menu items actions are called with
Grid.Test to control the item visibility.
def is default menu used for this menu. If not set, on toolbar it is "Tool" otherwise "Popup".
type are flags for the menu, it can be:
&
1 =
1 - if resulted menu contains only one visible item, it automatically calls its action and does not show the menu.
Grid method Menu
ShowMenu
(Row row, Col col, Menu menu = null, string def = "Popup" / "Tool", bits type = 0)
Shows menu for the cell
row,
col.
menu is Menu object to show, its format is the same
Menu. If not set, the
Menu is used.
Unlike the action
ShowMenu it always shows all the menu items and never calls the item actions to test their visibility.
def is default menu used for this menu. If not set, on toolbar it is "Tool" otherwise "Popup".
type are flags for the menu, it can be:
&
1 =
1 - if resulted menu contains only one visible item, it automatically calls its action and does not show the menu.
Returns the created menu Grid object.
API event bool
OnShowMenu
(Grid grid, Row row, Col col, Menu menu)
Called before showed menu
menu for cell
row,
col.
menu is the JSON
Menu object with Script.Items and Place.
Return true to not display the menu.
API event void
OnShowedMenu
(Grid grid, Row row, Col col, Grid menugrid)
Called after the menu was shown for given cell.
menugrid is grid displayed with the menu items.
List
Key / value pairs for cell value, used to convert value for display and to choose cell value from popup menu.
Uses FastGrid
menu for display.
To show the
List on click to icon set
LeftIcons
or
RightIcons or
TextIcons = "
List". The List icon is hidden for not editable cells (see
NoEdit).
To show the
List on click to the whole cell set
Button="
List". It will restrict inline editing of the cell. The List menu is not shown for not editable cell (see
NoEdit).
To show the
List on edit the cell set
Suggest>=
1.
List of applicable values for given cell. It can be:
a) | simple list | "|val1|val2|val3" or ["val1","val2","val3"] | The first character separated string or JSON array as simple list of values that can be used only for menu or suggest.
If set IndexList, it is list of values by index like b) {0:"val1",1:"val2",2:"val3"}. The index is set in cell value, the value is displayed in cell or menu. |
b) | key / value pairs | {key1:"val1",key2:"val2",key3:"val3"} | The key is set in cell value, the value is displayed in cell in grid or in menu item. |
c) | key / object pairs |
{key1:{Value:val1,Text:text1,Suggest:suggest1,Attr11:...,Attr12:...},
key2:{Value:val2,Text:text2,Suggest:suggest2,Attr21:...,Attr22:...},...} |
The key is set in cell value, the Value is displayed in cell in grid,
the Text is displayed in menu item,
the Suggest is used for Suggest search (if not set, Value is used).
The attributes Attr are applied for the cell text displayed in grid. The attributes can be text attributes: Type, Wrap, Align, TextColor, Format, ... |
The List is used to set cell values as key or index and to display the value assigned to the key or index.
The List is also used in popup menu displayed by Button
List if
ListMenu is empty or contains
*List item.
If the List item is "
-", it is shown in menu as inactive vertical separator.
If the cell contains value not listed in the
List, it displays the
NoListValue value.
Menu shown to choose cell value from the List. It can be:
a) | simple list | "|val1|val2|val3" or ["val1","val2","val3"] | The first character separated string or JSON array as simple list of menu items with the same texts and values.
|
b) | menu grid rows |
[{Value:value1,Text:text1,Suggest:suggest1,Attr11:...,Attr12:...},
{Value:value2,Text:text2,Suggest:suggest2,Attr21:...,Attr22:...}, ...] |
The Value is set to the cell value (and is also displayed in cell, if not updated by List), the Text is menu item text, the Suggest is used in SuggestMenu for suggest search (if not set, Value is used).
Attributes Attr are standard FastGrid menu item attributes to be applied to the menu item. They are not applied to the source grid cell! |
c) | full menu grid | {D:"...", Place:{...}, Tag1:..., Tag2:..., ..., Script:{ Items:[...], ... } } | Standard FastGrid Menu object with Tags like Cfg or Format. The Items contains the same the array as in the point b). |
For example:
{ id:"E", RightIcons:"List", Button:"List",
List:{a:{Value:'A',Text:'AA'},b:{Value:'B-red',Text:'BB',TextColor:'red'},c:{Value:'C',Text:'CC'}},
ListMenu:[{id:'a',Value:'AA'},{id:'b',Value:'BB',TextColor:'blue'},{id:'c',Value:'CC'}]
}
The default menu default (
D attribute) for List is "
List".
The ListMenu item
id (or the item itself if is string) can be special keyword starting by
*:
*List | replaced by items generated from the List |
*Rows / *Cols | replaced by items from other cells, by default from all rows / columns in the same column in all parts, it can contain next words started also by "*" (e.g. *Rows*PartBody*ColB): |
| *Visible | Only visible rows / columns |
| *Part | Only from actual part |
| *PartXXX | Only from Part XXX |
| *ColXXX / *RowXXX | From column / row XXX instead of actual column |
| *D | Only from rows / columns with the same D |
| *DXXX | Only from rows / columns with D:"XXX" |
| *MaxXXX | Maximally XXX items |
| *Filter | Only rows / columns that can be filtered (have not NoFilterRow:1 / NoFilterCol:1) |
| *Siblings | Only rows / columns from the same parent |
*FilterOff | replaced by item to clear actual filter, in Filter row only |
If the ListMenu item
id (or the item itself if is string) is "
-", it is shown as inactive vertical separator.
Comparing strings is controlled by Cfg attributes
ListCaseSensitive,
ListLocaleCompare,
ListWhiteChars
and cell attributes
CaseSensitive,
LocaleCompare,
WhiteChars,
CharCodes and
RemoveHtml.
An url to load
ListMenu from server on dialog show.
It can be set to string as direct url or to object as
Source, with attributes
Url,
Data,
Add,
Param,
Header,
Sync,
User,
Pass,
Safe,
Debug.
If not set
Method, it is used as AJAX "get".
The url string can contain keywords
*Row and
*Col to be replaced by the row and column
id that cell shows the dialog.
For
ListRelated list the url string can contain keywords
*Rel1,
*Rel2, ...to be replace by values in given related cells.
The row and column id of the cell with dialog are uploaded in parameters named
Row and
Col. It can be changed by
ListMenuParamNames.
For
ListRelated list the values in given related cells are uploaded in parameters named
Rel1,
Rel2, ...It can be changed by
ListMenuParamNames.
The loading is asynchronous.
The server response should contain the row with
ListMenu for given column.
For example:
FGrid.Data = { Body:[ { id:"Row3", A: { Col6: { ListMenu: "|A|B|C" } } } ] }
An url to load
ListMenu from server on dialog show, used instead of Cfg
ListMenuUrl.
If set, the
ListMenuUrl is loaded on every menu display. If not set, the menu is loaded only on the first menu show.
If set, the
ListMenuUrl is loaded on every menu display. If not set, the menu is loaded only on the first menu show. Used instead of Cfg
ListMenuReload.
Parameter names, comma separated, where to include: row id, column id, first related value, second related value, ...
If the third value (Rel) contains *, it is used for all the related names, replacing the * by related index (from 1).
String added before all custom relative urls. It should end by slash '/'.
It is also generated from actual url when
Save data by "Print" option.
Grid method void
LoadMenu
(Row row, Col col, function func, string attr = "ListMenu")
Starts loading children from
ListMenuUrl or
SuggestMenuUrl of given cell.
func is called after finish. If the
func returns true, the
Paint is not done.
attr can be "ListMenu" or "SuggestMenu".
API event bool
OnLoadMenu
(Grid grid, Row row, Col col, Source sourc)
Called before
ListMenu or
SuggestMenu is loaded from
source.
source is copy of the
ListMenuUrl or
SuggestMenuUrl and can be modified in this event handler.
Return true to not load the menu.
API event void
OnLoadedMenu
(Grid grid, Row row, Col col)
Called after
ListMenu or
SuggestMenu is loaded, before
paint.
Comma separated list or array of column ids the
List /
ListMenu are related to.
It defines dependent lists like Country -> State/County -> City.
The
List /
ListMenu for the cell are chosen according to value(s) in
ListRelated columns in the same row.
For example
{ id:"C", ListRelated:"A,B", List:{1:{1:"|A11|B11|C11",2:"|A12|B12|C12",3:"|A13|B13|C13"},2:{1:"|A21|B21",2:"|A22|B22|C22|D22"}}.
It shows different list in the "C" column according to the values 1,2 in column A and values 1,2,3 in column B.
The item in
ListRelated can be also array [row_id,col_id] to refer cell in another row, e.g.
ListRelated:["A",[2,"B"],[3,"B"]]
To hide List icon and button when no List is available, calculate it by Formula like:
Cols: [ { id:"Col1", DA:"Col1Def", ... }, ...],
DefCells: { Col1Def: { RightIconsFormula:"Grid.GetList(Row,Col)?'List':''", ButtonFormula:"Grid.GetList(Row,Col)?'List':''", NoEditFormula:"Grid.GetList(Row,Col)?3:1", ... }, ... }
Comma separated list or array of column ids that will be cleared (its value set to null) in the same row after the change of the cell. Usually used with
ListRelated for dependent lists.
The item in
ClearCells can be also array [row_id,col_id] to refer cell in another row, e.g.
ClearCells:["A",[2,"B"],[3,"B"]]
If set, even to empty string, this value is
displayed in cell, if the cell value is not in the cell
List.
If the string contains
*Value, it is replaced by the cell value.
If the string contains
*Number or
*Date, it is replaced by the cell value formatted as number or date according to the
NoListFormat.
Number or date format used for
*Number and
*Date in
NoListValue.
Controls editing the cell with the
List.
1. bit &
1 - If set, it permits only values existing in the List.
2. bit &
2 - If set, it permits entering also List keys.
3. bit &
4 - If set, it uses
ListCaseSensitive /
ListLocaleCompare /
ListWhiteChars /
CharCodes /
RemoveHtml when comparing the entered value with the List values (and keys).
How the
NoListValue replaces the unknown items in
Range cells.
0 - If there is at least one unknown item, the cell shows one
NoListValue.
1 - Every the unknown item is replaced by the
NoListValue.
If all items are unknown, the cell shows one
NoListValue.
2 - Every the unknown item is replaced by the
NoListValue.
If all items are unknown, the cell shows all the items as
NoListValue.
If
List set as array or string contains only values or values by index.
0 - List set as array or string contains only values, no conversion of cell value is done for display and edit.
1 - It is taken as
2 if cell's
IndexList is set, otherwise as
0.
2 - List set as array or string contains values by indexes. If cell value contains number, it displays value in the List on given index. After choosing List value from menu the cell value gets its index, except the cell value contained string.
If the cell contains string it is always displayed and set as is.
If
List set as array or string contains only values or values by index. It is read only if set
Cfg IndexList =
1.
If set, the cell is not used when generating
ListMenu by
*Rows.
If the strings in
ListMenu are compared as case sensitive.
Used only if the cell has not set the CaseSensitive attribute.
If set, compares strings in
ListMenu according to locale meaning.
Used only if the cell has not set the LocaleCompare attribute.
0 | a<b<á | according to unicode |
1 | a<á<b | according to default locale |
2 | a==á<b | according to default locale |
"locale" | a<á<b | according to specified locale (e.g. "en-US" or "cs-CZ") |
"=locale" | a==á<b | according to specified locale (e.g. "=en-US" or "=cs-CZ") |
List of characters to ignore when comparing strings in
ListMenu.
Used only if the cell has not set the WhiteChars attribute.
It can be set for example to " " (space) to ignore spaces (it means that for example "a b c" and "abc" strings are the same.
Actions, Cell, Tool void
OnChange
(Grid Grid, Row Row, Col Col, Event Event)
GetAttr SetAttr
JSON event handler (JavaScript code in string) called after the cell value is changed by a user - by editing the cell or changing it from the list or menu.
The
Event object contains special property
Value as original cell value before change and
Formula as original cell editable formula, if any, before change.
Actions
ShowList
(int target = 0)
OnClickList
Shows list menu for actual or focused cell, defined in
ListMenu attribute.
Grid method object
ShowList
(Row row, Col col)
Shows list menu for the cell
row,
col, defined in
ListMenu attribute.
Returns the created Menu object.
If the cell already shown the list menu, it closes the list menu and returns false.
Returns null if fails.
Grid method object
GetList
(Row row, Col col)
Returns
List or its part according to the
ListRelated.
API event bool
OnShowList
(Grid grid, Row row, Col col, Menu menu)
Called before showed list menu
menu for cell
row,
col.
menu is the JSON
Menu object with Script.Items and Place.
Return true to not display the list menu.
API event void
OnShowedList
(Grid grid, Row row, Col col, Grid menugrid)
Called after the list menu was shown for given cell.
menugrid is grid displayed with the menu items.
Suggest
Popup list shown during editing to suggest items according to the entered text part.
Uses FastGrid
menu for display with default dialog
Suggest or
FormulaSuggest.
If and when the suggest menu will be shown.
FormulaSuggest is used for suggest formula function in editing formula.
0 - suggest is never shown,
1 - suggest is shown after first change,
2 - suggest is shown also on start editing,
3 - suggest is shown always and with all items.
For Sheet the default FormulaSuggest is set to 1.
Menu shown to suggest items for actual entered text. The format is the same as
ListMenu
The SuggestMenu can contain simple menu items (no Bool/Edit/List/Menu) and only one column (no Columns).
An url to load
SuggestMenu from server on dialog show.
It can be set to string as direct url or to object as
Source, with attributes
Url,
Data,
Add,
Param,
Header,
Sync,
User,
Pass,
Safe,
Debug.
If not set
Method, it is used as AJAX "get".
The url string can contain keywords
*Row and
*Col to be replaced by the row and column
id that cell shows the dialog.
The url string can contain keyword
*Value to be replaced by actually edited value (use with
SuggestMenuReload =
2).
The row and column id of the cell with dialog are uploaded in parameters named
Row and
Col. It can be changed by
SuggestMenuParamNames.
The edited value is uploaded in parameter
Value (use with
SuggestMenuReload =
2).
The loading is asynchronous.
The server response should contain the row with
SuggestMenu for given column.
For example:
FGrid.Data = { Body:[ { id:"Row3", A: { Col6: { SuggestMenu: "|A|B|C" } } } ] }
An url to load
SuggestMenu from server on dialog show, used instead of Cfg
SuggestMenuUrl.
If set to
2, the
SuggestMenuUrl is loaded on every value change during editing. Use when server changes the suggest menu according to the edited value.
If set to
1, the
SuggestMenuUrl is loaded on every start editing.
If set to
0, the
SuggestMenuUrl is loaded only on the first start editing.
If set to
2, the
SuggestMenuUrl is loaded on every value change during editing. Use when server changes the suggest menu according to the edited value.
If set to
1, the
SuggestMenuUrl is loaded on every start editing.
If set to
0, the
SuggestMenuUrl is loaded only on the first start editing.
Used instead of Cfg
ListMenuReload.
Parameter names, comma separated, where to include: row id, column id, value to get suggest for.
String added before all custom relative urls. It should end by slash '/'.
It is also generated from actual url when
Save data by "Print" option.
Grid method void
LoadMenu
(Row row, Col col, function func, string attr = "ListMenu")
Starts loading children from
ListMenuUrl or
SuggestMenuUrl of given cell.
func is called after finish. If the
func returns true, the
Paint is not done.
attr can be "ListMenu" or "SuggestMenu".
API event bool
OnLoadMenu
(Grid grid, Row row, Col col, Source sourc)
Called before
ListMenu or
SuggestMenu is loaded from
source.
source is copy of the
ListMenuUrl or
SuggestMenuUrl and can be modified in this event handler.
Return true to not load the menu.
API event void
OnLoadedMenu
(Grid grid, Row row, Col col)
Called after
ListMenu or
SuggestMenu is loaded, before
paint.
Minimal count of entered characters to show the suggest.
Cell, Tool int
SuggestSearch / FormulaSuggestSearch
[0] GetAttr SetAttr
Where searches for the entered text.
0 - only on the item start,
1 - on start of every word,
2 - anywhere in the item text.
Flags for suggest. &
1 - case sensitive, &
2 - ignore WhiteChars, &
4 use CharCodes, &
8 ignore HTML code.
Cell, Tool bool
SuggestExisting / FormulaSuggestExisting
[0] GetAttr SetAttr
For
1 restricts entering value that does not exist in
List.
Cell, Tool bits
SuggestReplace / FormulaSuggestReplace
[0] GetAttr SetAttr
When the cell is replaced on choosing Suggest menu item.
&
1 - replace value on suggest menu focus change (by arrow keys).
&
2 - replace value on suggest menu click (always when used SuggestSeparator), otherwise (for
0) finishes editing.
Cell, Tool bool
SuggestComplete / FormulaSuggestComplete
[0] GetAttr SetAttr
Automatically enters the suggested value if there is only one suggested value.
Cell, Tool bool
SuggestFocus / FormulaSuggestFocus
[0] / [0/1] GetAttr SetAttr
If set, focuses the first in item in suggest menu to be chosen by enter.
For Sheet the default FormulaSuggestFocus is set to 1.
Cell, Tool bits
SuggestKeys / FormulaSuggestKeys
[0] / [0/5] GetAttr SetAttr
Flags for keys control in Suggest menu.
&
1 - up / down keys in multiline:
0 - without ctrl move caret, with crtl move in menu,
1 - without ctrl move in menu, with ctrl move caret.
&
2 -
2 first press of esc hides the Suggest menu until editing finishes.
&
4 -
4 Tab chooses the focused item like Enter.
For Sheet the default FormulaSuggestKeys is 5.
Cell, Tool string
SuggestSeparator / FormulaSuggestSeparator
[ ] / [...] GetAttr SetAttr
If set, it searches only the entered part with caret between these separators or text start / end.
After choosing suggested value it does not finish editing.
Default value is none for standard cell and
ValueSeparator for
Range cell.
It can be regex, if set
SuggestSeparatorType&
4.
For Sheet the default FormulaSuggestSeparator is set to "[^a-zA-Z\.]".
Cell, Tool bits
SuggestSeparatorType / FormulaSuggestSeparatorType
[0] / [0/5] GetAttr SetAttr
Flags used with
SuggestSeparator.
&
1 - add
SuggestSeparatorAdd or the separator itself after chosen suggested value.
&
2 - place caret before separator when chosen suggested value.
&
4 -
SuggestSeparator is regex.
For Sheet the default FormulaSuggestSeparatorType is set to 5.
Cell, Tool char
SuggestSeparatorAdd / FormulaSuggestSeparatorAdd
[ ] / ["" / "("] GetAttr SetAttr
What will be added for
SuggestSeparatorType&
1 after chosen suggested value. If not set,
SuggestSeparator is added.
For Sheet the default FormulaSuggestSeparatorAdd is set to "(".
API event bool
OnShowSuggest
(Grid grid, Row row, Col col, Menu menu, bool formula)
Called before showed suggest menu
menu for cell
row,
col for first time.
menu is the JSON
Menu object with Script.Items and Place, it contains all available items.
formula is set for
FormulaSuggest when suggesting function in editing formula.
Return true to not display the suggest menu at all.
API event void
OnShowedSuggest
(Grid grid, Row row, Col col, Grid menugrid, bool formula)
Called after the suggest menu was shown for given cell, but repainted with actually suggested rows by
Paint().
It is called after every update of the suggested items. The grid contains always all items available for suggest, but the unsuitable items for actual input are hidden.
formula is set for
FormulaSuggest when suggesting function in editing formula.
menugrid is grid displayed with the suggest menu items.