FANDOM


This page is based on http://lessons.runrev.com/s/lessons/m/datagrid/l/7344-data-grid-api and other pages, since they are difficult to reach , I have added all them here.

Index and lines refers to rows but in different way: lines refer to the current sort, on the contrary the indexes refer to the array line value, so indexes are independents from the sort. User may sort the datagrid table as he likes, just clicking on the column titles.

The properties and custom properties refer to datagrid properties.


General Properties Edit

All general data grid properties are stored in the dgProps custom property set. To access a property you can use dgProps or dgProp:

put the dgProp[ "PROPERTY_NAME" ] of group "Data Grid"

allow editingEdit

Set to true to allow users to edit the cells of a table or the fields in a form. Note that when customizing templates for form rows or table columns you would check this property to determine if fields should allow editing. The default Row Behavior script contains an example of how to do this.

set the dgProp["allow editing"] of group "Data Grid" to true

alternate row colorEdit

The color of every other row's background. Default value is empty in which case a default hilite color is used. Only applicable when 'alternate row colors' is true. Prefix property name with "effective" to get the color being used.

set the dgprop["effective alternate row color"] of group 1 to "230,237,247"

alternate row colorsEdit

Set to true to alternate the background colors of every other row.

auto hiliteEdit

Set to true if you would like the data grid to automatically handle row highlighting in response to user interaction.

background colorEdit

The background color of the data grid. Note that if 'alternate row colors' is true then the alternating row colors will cover the background.

cache controlsEdit

By default the data grid only draws the controls that are visible on the screen. In circumstances where you don't have large amounts of records but the records you have take a long time to draw you may cache all of the controls when the data grid is drawn. This takes a little longer to display at the beginning but will offer smooth scrolling when the user interacts with the data grid.

column divider colorEdit

Sets the color of the table column dividers. Prefix property name with "effective" to get the color being used when this property is set to empty

column marginsEdit

Specifies the margins to be applied to each cell in a column.

control typeEdit

Returns "data grid". You can check this property to determine if a group is a data grid.

dim on focusOutEdit

If true then the highlighted lines will be dimmed to 'dimmed hilite color' when the data grid does not have focus. Default is true.

dimmed hilite colorEdit

Color that highlighted lines will be when control is not focused. Prefix property name with "effective" to get the color being used when this property is set to empty.

fixed row heightEdit

Set to true if all of your data will be drawn at the same height. Setting this to true will dramatically improve performance the first time the data grid is drawn as the data grid does not have to determine the height of all of your records before drawing. Default value is true.

Example:

set the dgProp["fixed row height"] of group "my Data Grid" to false

hilite colorEdit

The color to use when highlighting a row. If empty then the hiliteColor property is used. Prefix property name with "effective" to get the color being used when this property is set to empty

hilited text colorEdit

The color to apply to text when a row is highlighted. By default this property is empty in which case the color is black if the average of the RGB value for the hilite color > 128, white otherwise.

multiple linesEdit

Set to true to allow the user to select multiple lines in the data grid.

opaqueEdit

Shows or hides the data grid background.

persistent dataEdit

Set to true if you would like the data grid to store the data being displayed between sessions. The data grid always works with data stored in a script local variable but if this value is true then the data will be cached in a custom property as well. This will double the memory used so this is suitable for small lists. For large data sets you should set this property to 'false' and set the data grid data each time the data grid is opened. The default value is 'true'.

row colorEdit

The primary row color. This color alternates with 'alternate row color'. Prefix property name with "effective" to get the color being used when this property is set to empty

row heightEdit

For tables and forms whose 'fixed row height' property is true this represents the height that your rows will be drawn at. If this property is not set for a form whose 'fixed control height' is true then the record template group height is used. For forms whose 'fixed control height' is false this represents the height that alternating rows that contain no data will be drawn at.

row templateEdit

This is the group that represents a record in your data grid. If the style of the data grid is form then this group will be copied into the data grid. If the data grid style is table then the data grid looks in this group for controls named after the columns in your table. If the data grid finds a control in this group that matches a column name then the control will be used to visually represent the column. Otherwise a field is used.

By default the Revolution IDE creates this group on a card in a stack whose name starts with "Data Grid Template". Clicking the "Row Template" button in the Property Inspector reveal the card containing this group.

scroll when hscrollbar is hiddenEdit

By default a data grid will not respond to the mouse scroll wheel, page up, page down, home or end if the scrollbar is hidden. Set this property to true if you would like to override this behavior. This is useful if you want to create custom scrollbars.

scroll when vscrollbar is hiddenEdit

By default a data grid will not respond to the mouse scroll wheel, page up, page down, home or end if the scrollbar is hidden. Set this property to true if you would like to override this behavior. This is useful if you want to create custom scrollbars.

scrollbar corner offsetEdit

This property is an integer that specifies the distance from the corner of the window that the vertical and horizontal scrollbars position themselves when only one of them is visible. This is primarily useful on OS X when your data grid reaches all the way to the bottom right corner of the window where the window drag handle appears. Setting this to a value like "15" will keep your scrollbar controls from being hidden behind the window drag handle. Default value is "0".

show vscrollbarEdit

Toggles the visibility of the vertical scrollbar. True, false, or auto.

show hscrollbarEdit

Toggles the visibility of the horizontal scrollbar for a table. True, false or auto.

scrollbar widthEdit

Set to an integer or to auto if you would like the data grid to set the appropriate width based on the platform it is being displayed on. Default is auto. When set to auto you can retrieve the actual width in pixels using effective scrollbar width.

styleEdit

'form' or 'table'.

text colorEdit

The text color to apply to the data area of a table or form. Prefix property name with "effective" to get the color being used when this property is set to empty

text fontEdit

The font to apply to the data area of a table or form. Prefix property name with "effective" to get the font being used when this property is set to empty.

text sizeEdit

The text size to apply to the data area of a table or form. Prefix property name with "effective" to get the size being used when this property is set to empty

text styleEdit

The text style to apply to the data area of a table or form. Prefix property name with "effective" to get the style being used when this property is set to empty

Table PropertiesEdit

All data grid table properties are stored in the dgProps custom property set. To access a property you can use dgProps or dgProp:

put the dgProp[ PROPERTY_NAME ] of group "Data Grid"

allow column resizingEdit

If true then the user can resize columns in the table header. Note that you can also turn off resizing for individual columns which would override this setting.

set the dgProp["allow column resizing"] of group "Data Grid" to true

column divider colorEdit

The color of the column dividers in a table.

column alignmentsEdit

Allows you to set all column alignment values at once. Line delimited list of alignment values.

column visibilityEdit

Allows you to set the visible property for all columns at once. Line delimited list of boolean values.

column widthsEdit

Allows you to set all column widths at once. Comma delimited list of integers.

columnsEdit

Line delimited list of columns in your table. For example:

set the dgProp["columns"]  of group "myTable" to "Column 1" & return & "My Perfect Column 2"


column labelsEdit

Line delimited list of labels for columns in your table.

set the dgProp["column labels"]  of group "myTable" to ("Column 1" & return & "My Perfect Column 2")

corner colorEdit

The color of the corner piece that appears when both horizontal and vertical scrollbars are visible. You set set to a solid color, a gradient (two colors, one per line) or an array containing the keys of the fillGradient property.

default column behaviorEdit

The table style has an internal behavior that is used for columns which have no custom control defined for them. This behavior sets the text of a field as well as the alignment, etc. You can set this property to a button containing the default behavior you would like. This can be useful if you need to display html, unicode or rtf text among other things. The default value is empty.

To see the script that the data grid uses by default for columns you can edit the script of button "Default Column" of group "Behaviors" of stack "revDataGridLibrary"

default header behaviorEdit

The table style has an internal behavior that is used for column headers. If you would like to override the default behavior for column headers you can set this property to point to a button with your own behavior script.

To see the script that the data grid uses by default you can edit the script of button "Default Header" of group "Behaviors" of stack "revDataGridLibrary"

header background colorEdit

The background color of the header. You set set to a solid color, a gradient (two colors, one per line) or an array containing the keys of the fillGradient property.

header background hilite colorEdit

The background color of the header that is being sorted by. You set set to a solid color, a gradient (two colors, one per line) or an array containing the keys of the fillGradient property.

header heightEdit

The height of the header are of the table.

header marginsEdit

Specifies the margins to be applied to the fields that display the header text.

header text colorEdit

The text color to apply to the header area of a table. Prefix property name with "effective" to get the color being used when this property is set to empty

header text fontEdit

The font to apply to the header area of a table. Prefix property name with "effective" to get the font being used when this property is set to empty

header text sizeEdit

The text size to apply to the header area of a table. Prefix property name with "effective" to get the size being used when this property is set to empty

header text styleEdit

The text style to apply to the header area of a table. Prefix property name with "effective" to get the style being used when this property is set to empty

show column dividersEdit

Toggles the visibility of the column dividers in the data display area. Default value is true.

show column dividersEdit

Toggles the visibility of the column dividers that appear in the data area.

show headerEdit

Toggles the visibility of the header. Default value is true.

sort by columnEdit

The column that the table data is currently being sorted by. You can set this property to sort by a new column. Use the column name.

set the dgProps["sort by column"] of group "Data Grid" to "Col 1"

visible columnsEdit

Line delimited list of columns in your table that are visible.

Column PropertiesEdit

These properties allow you to set properties of individual columns in a table. The syntax you use resembles:

set the dgColumnSortType [ COLUMN ] of group "Data Grid" to "numeric"

where COLUMN is the name of the column you are targeting.

dgColumnAlignment [COLUMN]Edit

Get/set the alignment for a column. Valid values are 'left', 'right' or 'center'.

set the dgColumnAlignment["names"] of group "Data Grid" to "left"

dgColumnIsEditable [COLUMN]Edit

Toggle whether or not a column is editable by the user. Set to true/false.

dgColumnIsVisible [COLUMN]Edit

Get/set the visibility of the column.

dgColumnIsResizable [COLUMN]Edit

Get/set whether or not a column is resizable.

dgColumnLabel [COLUMN]Edit

Get/set the label used for the column. If the label is empty then the column name is used.

dgColumnMaxWidth [COLUMN]Edit

Get/Set the maximum width that a column can be resized to.

dgColumnMinWidth [COLUMN]Edit

Get/Set the minimum width that a column can be resized to.

dgColumnName [COLUMN] pNewNameEdit

Set a new name for a column.

dgColumnTemplate [COLUMN]Edit

Get the control that is used to visually represent the column in the table. This control will be a control in the 'row template' group with the same name as the column. If no matching control exists then a field is used.

dgColumnTooltip [COLUMN]Edit

Set the tooltip that appears when the mouse is over the column header.

dgHeaderTemplate [COLUMN]Edit

Get the control that is used to visually represent the header for a column. This control will be a control in the 'row template' group name "COLUMN [Header]". If no matching control exists then the deafult header control is used.

dgColumnSortDirection [COLUMN]Edit

Get/set the direction of the sort for the column. Valid values are 'ascending' or 'descending'.

dgColumnSortIsCaseSensitive [COLUMN]Edit

Get/set whether or not column sort is case sensitive. Default value is false.

dgColumnSortType [COLUMN]Edit

Get/set the sort type of the column to 'text', 'numeric', 'datetime' or 'system datetime'.

dgColumnWidth [COLUMN]Edit

Get/set the width of a column.

dgHeaderAlignment [COLUMN]Edit

Get/set the alignment for a column's header.

Template Field Editor PropertiesEdit

The template field editor properties are set using the dgTemplateFieldEditor custom property.

set the dgTemplateFieldEditor[ PROPERTY_NAME ] of group "Data Grid" to SOME_VALUE

select textEdit

Set to true to select all text in the field editor.

textEdit

Set to a string that will be assigned to the text property of the field editor.

htmltextEdit

Set to a string that will be assigned to the htmltext property of the field editor.

rtftextEdit

Set to a string that will be assigned to the rtftext property of the field editor.

unicodetextEdit

Set to a string that will be assigned to the unicodetext property of the field editor.

utf8textEdit

Set to a string that will be assigned to the unicodetext property of the field editor after being converted from UTF-8 to UTF16.

Table Header PropertiesEdit

dgHeaderEdit

Returns the long id of the group that contains the controls for the table header. Use this property in a mouseDown/mouseUp handler to determine if the user clicked on a the table header.

If the dgHeader of the target is not empty then 
  ... (user clicked in table header).

dgHeaderControlEdit

Returns the long id of the group that contains the controls for a column header. Use this property in a mouseDown/mouseUp handler to determine if the user clicked on a column header.

If the dgHeaderControl of the target is not empty then
  ... (user clicked in a column header).

Custom PropertiesEdit

dgControlEdit

 get the dgControl of the target

Returns the long id of the data grid. Useful in row/column template behaviors when you need to get properties of the data grid.

dgDataEdit

get the dgData
set the dgData of group "DataGrid" to pDataArray

Get or set the data array that the data grid will display. The array organization is the following: dgData[row][column_name], where row is an integer and column_name is a string. The first dimension of the array uses numeric keys and the value of each is an array. You can store anything you would like in each numeric key's array. For data grid tables the keys should match the column names in order for the data grid to correctly map the array value to the column cell. The following array would represent two records in the data grid:

put "Hi" into theA[1]["message"]
put "Bye" into theA[2]["message"]

set the dgData of group "DataGrid" to theA


dgDataControlOfIndexEdit

get the dgDataControlOfIndex [ pIndex ]

DATA GRID FORMS ONLY! Returns the long id of the data control associated with an index. If "cache controls" is not turned on then this property returns empty if the index has no control associated with it because it is offscreen.

get the dgDataControlOfLine [ pLine ]

Same as dgDataControlOfIndex but takes a line number as the parameter.


dgDataOfIndexEdit

get the dgDataOfIndex [ pIndex ] 
set the dgDataOfIndex [ pIndex ] of group "DataGrid" to pDataA

Get or set the data associated with a particular index. The value is the array assigned to that index. Note that setting the data of an index will cause the data grid to refresh the row associated with the index if it is visible on screen.

put the dgDataOfIndex[1] of group "DataGrid" into theMessageA
put theMessageA["message"] -- puts "hi"

The value is an array, with keys the column names. Example:

put the dgDataOfIndex[1] of group "DataGrid" into temp
put temp["column1"] -- puts "hello world!"

dgDataOfLineEdit

get the dgDataOfLine [ pLine ]
set the dgDataOfLine [ pLine ] of group "DataGrid" to pDataA

Get or set the data associated with a particular line. The value is the array assigned to that line. Note that setting the data of a line will cause the data grid to refresh the line if it is visible on screen.

put the dgDataOfLine[1] of group "DataGrid" into theMessageA
put theMessageA["message"] -- puts "hi"

dgFocusEdit

set the dgFocus of group "DataGrid" to true

Set to true to focus on a data grid.

dgFormattedHeightEdit

get the dgFormattedHeight

Returns the formatted height of the data in the data grid. The table header is not included in the formatted height.

dgFormattedWidthEdit

get the dgFormattedWidth

Returns the formatted width of the columns in a data grid. This is only useful in tables as forms don't scroll horizontally.

dgNumberOfLinesEdit

Returns the number of lines displayed in the data grid.

dgNumberOfRecordsEdit

get the dgNumberOfRecords
set the dgNumberOfRecords of group "DataGrid" to 20

Getting the dgNumberOfRecords is the same as getting the dgNumberOfLines. Setting the dgNumberOfRecords has a special significance however. If you set the dgNumberOfRecords then you are telling the data grid that you know how many total records there are and you are going to supply the data for each record on an as-needed basis. This is useful when you have data in a database cursor that you would like to feed into the data grid.

After setting this property the data grid will send the GetDataForLine message to the data grid whenever it needs to display data for a particular line. You can define this command in the data grid script or elsewhere in the hierarchy. The definition is as follows:

command GetDataForLine pLine, @pDataA
...
end GetDataForLine

You should fill pDataA with the appropriate data based on the line of data being requested. pDataA should not have a numeric index. It is the array that would be assigned to one of the numeric indexes if you were assigning the dgData property.

dgTextEdit

get the dgText[pIncludeColumnNames]
set the dgText[pFirstLineContainsHeaders] of group "DataGrid" to pText

The data grid works with arrays behind the scenes but in the interest of making life easier for some folks there is a dgText property. The dgText property always reflects the same value as the dgData but in tab delimited form.

pText is assumed to be a collection of data where each row is delimited by the return character and each item is delimited by a tab. You can map each item of each line in pText to a particular key in an array (and thus a table column) by passing in true for pFirstLineContainsHeaders. If true then the data grid will extract the first line of pText and use the values for the internal key/column names. The default value for pFirstLineContainsHeaders' is false.  Example

set the dgText[true] of group "DataGrid" to myTable

If you set the dgText of a data grid table then all data will be imported and assigned to the appropriate column depending on the value of pFirstLineContainsHeaders'. Normally you should set this property to true and provide the header that maps each item of each line to a specific column. Note that if pFirstLineContainsHeaders is true then the columns must already exist in your data grid table in order to be displayed.

If pFirstLineContainsHeaders' is false then the columns property of the data grid is used for mapping. For example, the first item of a line of pText would be assigned to the column that appears on the first line in the columns property of the data grid. If line 1 of pText contains more items than there are columns in the table then new columns are added. Any new columns are named "Col 1", "Col 2", etc.

If you set the dgText property of a data grid form then the data will be imported but it is up to you to modify your Row Template Behavior to display the imported data correctly. If pFirstLineContainsHeaders' is false then each item of each line in pText' will be named "Label X" (where X is the item number) in the array that is passed to FillInData.

When retrieving the dgText property you can include the column names in the first line by setting pIncludeColumnNames to true.

dgHilitedIndexes & dgHilitedIndexEdit

get the dgHilitedIndexes
set the dgHilitedIndexes of group "DataGrid" to pIndex

Returns a comma delimited list of the indexes that are currently selected.

dgHilitedLines & dgHilitedLineEdit

get the dgHilitedLines
set the dgHilitedLines of group "DataGrid" to pLine

Returns a comma delimited list of the line numbers that are currently selected.

dgHScrollEdit

get the dgHScroll
set the dgHScroll  of group "DataGrid" to pInteger

Get/set the horizontal scroll of the data grid. This only applies to tables as forms do not scroll horizontally.

dgHScrollPercentEdit

get the dgHScrollPercent
set the dgHScrollPercent of group "DataGrid" to pPercent

Get/set the percentage of the horizontal scroll. A number between 0 and 1. This only applies to tables as forms do not scroll horizontally.

dgIndexesEdit

get the dgIndexes

Returns the internal list of indexes in the order in which they appear in the data grid. Indexes are the numeric indices used when setting the dgData property.

dgIndexOfLineEdit

put the dgIndexOfLine [ pLine ]

Returns the index associated with the given line.

dgVScrollEdit

get the dgVScroll
set the dgVScroll of group "DataGrid" to pInteger

Get/set the vertical scroll of the data grid.

dgVScrollPercentEdit

get the dgVScrollPercent
set the dgVScrollPercent of group "DataGrid" to pPercent

Get/set the percentage of the vertical scroll. A number between 0 and 1.

dgVisibleLinesEdit

Returns the first and last line being displayed in the data grid as a comma delimited list. Useful if you want to provide visual feedback as to which lines are being displayed.

CommandsEdit

The following are commands you can issue to the data grid. To issue a command you can use 'dispatch' (introduced in 3.5) or 'send'. I prefer 'dispatch' as it has the nice 'with' syntax for sending parameters.

using dispatchEdit

put "value" into theArray["property"]
dispatch "AddData" to group "DataGrid" with theArray

using send Edit

put "value" into theArray["property"]
send "AddData theArray" to group "DataGrid"


AddDataEdit

AddData pDataArray, pLine

Use this command to add data to the data grid after you have already populated it by setting the dgData or dgText. pDataArray is an array of custom data to add to the data grid and pLine is the line number where it should be added. All data appearing at or after pLine will be shifted down 1. You will not overwrite any data. If pLine is empty then the data will be added to the end of the existing data.

If the data is successfully added then the index of the data will be returned in the result, otherwise an error is returned.

AddLineEdit

AddLine pText, pColumns, pLine

Use this command to add tab delimited text to the data grid after you have already populated it by setting the dgData or dgText. pText is tab delimited text to add to the data grid. pColumns is a cr delimited list of column names that text items map to. pLine is the line number where it should be added. All data appearing at or after pLine will be shifted down 1. You will not overwrite any data. If pColumns is empty then the "columns" property of the data grid is assumed. If pLine is empty then the data will be added to the end of the existing data.

CancelAnimationEdit

cancelAnimation

Used to stop the scroll animation.

DeleteIndex & DeleteIndexesEdit

DeleteIndexes pIndexes

Deletes the specified indexes from the data grid. pIndexes is a comma delimited list of integers.

DeleteLine & DeleteLinesEdit

DeleteLines pLines

Deletes the specified lines from the data grid. pLines is a comma delimited list of integers.

EditCellEdit

EditCell pColumnName, pLineNo

Sends the EditValue message to the column control for column pColumnName of line pLineNo. The default behaviors for columns handle the EditValue message and open the cell for editing by calling EditFieldText. Can only be used with tables.

EditCellOfIndexEdit

EditCellOfIndex pColumnName, pIndex

Same as EditCell but uses an index rather than a line number to locate the line to edit.

EditFieldTextEdit

EditFieldText pField, pIndex, pKey

This command will dynamically create an editable field for editing the contents of pField (pass in the long id of a field for pField). Calling EditFieldText will trigger additional messages related to field editing.

Scenario 1: Pass in one parameter

If you just pass in pField and leave pIndex and pKey empty then the data grid behaves as follows:

  1. Creates field editor
  2. Assign text of pField to field editor.
  3. Sends preOpenFieldEditor pFieldEditor to pField. pFieldEditor is the long id of the field editor created in step 1.

When editing stops (focus leaves field, user presses escape key, etc.) the message DeleteFieldEditor is sent to the data grid. This in turn sends CloseFieldEditor pFieldEditor to pField if the user changed the content or ExitFieldEditor pFieldEditor if no change was made. You can use these messages to save any changes the user made in pFieldEditor.

Scenario 2: Pass in all three parameters

If you pass in all three parameters (pField, pIndex, pKey) then the data grid will automatically save any changes made while editing. The new value will be assigned to the key pKey for index pIndex in the dgData array of the data grid.

In this scenarios CloseFieldEditor pFieldEditor and ExitFieldEditor pFieldEditor are still sent. The difference is that after CloseFieldEditor is sent to pField the contents of pFieldEditor are saved in the dgData. If for any reason you do not want the data to be saved then you can return "cancel" from CloseFieldEditor.

Note: If the user presses the tab key while editing and the autotab property of pField is true then the message OpenNextFieldEditor pDirection is sent to pField. If you don't handle this message and the data grid is a table then the data grid automatically opens the next cell for editing. For data grid forms you can handle this message in order to open another field for editing. You could call EditKeyOfIndex for example.

Note 2: The default behavior for pFieldEditor is located in button "Field Editor" of stack "revDataGridLibrary". If you want to override this behavior then you can assign the behavior of pFieldEditor to another button in the preOpenFieldEditor message.

EditKeyEdit

EditKey pKey, pLineNo

Sends the EditValue pKey message to the row control for line pLineNo. Handle the EditValue message in your data grid form row behavior in order to open a field in the row for editing. See EditFieldText.

EditKeyOfIndexEdit

EditKeyOfIndex pKey, pIndex

Same as EditKey but uses an index rather than a line number to located the line to edit.

FindIndex / FindLineEdit

FindIndex pKey, pSearchString

Search for data in pKey that matches pSearchString. pKey is one of the custom defined keys you defined for your data. pSearchingString is the value to look for in that key. You can pass multiple pKey=pSearchString combinations to match multiple criteria.

-- Find the index where "message" is "hi"
dispatch "FindIndex" to group "DataGrid" with "message", "hi"
put the result into theIndex

Note that pKey can also be an array if you want to use array-valued array indexing to locate pSearchingString.

RefreshIndexEdit

RefreshIndex pIndexes

Redraws row associated with pIndexes using latest data. Use this command in conjunction with SetDataOfIndex. pIndexes can be a comma delimited list of indexes.

RefreshLineEdit

RefreshLine pLines

Redraws row using latest data. Use this command in conjunction with SetDataOfLine. pLines can be a comma delimited list of lines.

ScrollIndexIntoViewEdit

ScrollIndexIntoView pIndex

Scrolls the data grid so that the line associated with pIndex in the internal data array is in view.

ScrollLineIntoViewEdit

ScrollLineIntoView pLine

Scrolls the data grid so that pLine is in view.

SelectAllEdit

Selects all lines in the data grid.

SetDataOfIndexEdit

SetDataOfIndex pIndex, pKey, pValue

Updates the key pIndex in the internal data array. If pKey is empty then pValue should be an array. pValue will be assigned to key pIndex in the internal data array. If pKey is not empty then pValue will be assigned to key pKey of key pIndex in the internal data array. The data grid display will not be updated to reflect the new values. To update the display call RefreshIndex. Use dgDataOfIndex if you want to automatically refresh the data grid when you update the data.

SetDataOfLineEdit

SetDataOfLine pLine, pKey, pValue

Updates the internal array of line pLine in the data grid. See notes for SetDataOfIndex.

SortByColumnEdit

SortByColumn pColumn

Pass in a column to sort by. The current sort properties of the column will be used to perform the sort.

SortDataByKeyEdit

SortDataByKey pArrayKey, pSortType, pDirection, pCaseSensitive

SortDataByKey is the underlying command that all column sorts call. It can be used to sort data grid forms. pArrayKey is one the keys you created when you assigned set dgData property. If you used the dgText property then the key will be "Label 1" or "Label 2", etc. pSortType, pDirection and pCaseSensitive all reflect the equivalent parameters for the built-in 'sort container' command in Revolution. pSortType is "text", "numeric', "dateTime" or "international". pDirection is "ascending" or "descending". pCaseSensitive is true/false.

RefreshListEdit

Redraws the data displayed in the data grid.

ResetControlEdit

Resets the control by clearing out any data.

ResetListEdit

Redraws the data grid data after having copied in fresh copies of any templates.

ResizeToFitEdit

Used internally when the rect of the data grid changes. Normally you will not need to call this handler as setting the rect of the data grid will trigger it.

FunctionsEdit

ColumnControlOfIndexEdit

ColumnControlOfIndex (pColumnName, pIndex)

DATA GRID TABLES ONLY! Returns the control for the column of index pIndex in the Data Grid. If "cache" controls" is not true then this may return empty if the row the index is displayed in is currently offscreen.

GetDataOfIndexEdit

GetDataOfIndex (pIndex, pKey)

Retrieves the internal array for key pIndex of the internal array in the data grid. If pKey is empty then the array associated with key pIndex in the internal data array will be returned. If pKey is not empty then the value of that key for key pIndex of the internal data array will be returned.

GetDataOfLineEdit

GetDataOfLine (pLine, pKey)

Retrieves the internal array associated with line pLine in the data grid. See notes for GetDataOfIndex.

Messages SentEdit

FillInDataEdit

The FillInData message is where you move data for a row or column into the controls for that row or column. Normally you will just assign data to controls in the template. You most likely will not resize any of the controls at this point. If your data grid is of type "form" then pData will be an array holding the row values. If your data grid is of type "table" then pData is the value for the column that is being populated.

Examples:

# Datagrid row behavior
on FillInData pDataA
  ## Assign FirstName value to the "FirstName" field of this row template
  set the text of field "FirstName" of me to pDataA["FirstName"] 
end FillInData 
# Data Grid table 
on FillInData pData
 ## Assign Column value to field 1 of this column template
 set the text of field 1 of me to pData 
end FillInData


LayoutControlEdit

Syntax

on LayoutControl pControlRect 
  set the rect of field "FirstName" to pControlRect 
end LayoutControl

LayoutControl is sent to your custom template when it is time to position all of the controls. pControlRect is the rectangle that the data grid has resized your control to. This is useful for knowing the left (item 1 of pControlRect), top (item 2 of pControlRect), right (item 3 of pControlRect) and bottom (item 4 of pControlRect) bounds you can position controls at.

Note that if you have a data grid form that does not have fixed height set to true then you can ignore the bottom (item 4 of pControlRect) and make your control as tall as you need.

selectionChangedEdit

selectionChanged pHilitedIndexes, pPreviouslyHilitedIndexes

Sent whenever the user changes the selection through some sort of user interaction. Handle this message in order to update your UI when the user makes a selection.

-- example that would be placed in the data grid script.
on selectionChanged pHilitedIndex, pPrevHilitedIndex
  put the dgDataOfIndex [ pHilitedIndex ] of me into theSelDataA
  uiViewRecordOfID theSelDataA["id"]
end selectionChanged

EditValueEdit

EditValue pKey

The EditValue message is sent to a table column control when EditCell or EditCellOfIndex is called. In this scenario there is no pKey parameter since the key is the column associated with the column control the message was sent to. Tip: use the dgColumn property of a column template to get the name of a column in the column control.

The EditValue message is sent to a row when EditKey or EditKeyOfIndex is called. In this case the first parameter is the name of the key in dgData that should be edited. Normally you will call EditFieldText from within the EditValue message in order to open a field editor for changing the contents.

CloseFieldEditorEdit

CloseFieldEditor pFieldEditor

This message is automatically sent to the group when the user change the value of a cell. For example in order to get row, column and text typed you can use:

on CloseFieldEditor pFieldEditor
   put the dgIndex of the target into theRow
   put the dgColumn of the target into theColumnBeingEdited
   put the text of pFieldEditor into theNewText    
end CloseFieldEditor

Note that we need time to execute datagrid update, so if you need to do something with datagrid data, you need to delay your intention like this:

on CloseFieldEditor 
   send "updateDatagridTotal" to me in 0.5 sec
end CloseFieldEditor

PreOpenFieldEditorEdit

PreFillInDataEdit

ResetDataEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.