| GRIDPLUS2 - Updating a Tablelist Row | ![]() |
||||||
|
| Updating a Tablelist Row |
GRIDPLUS provides the gpupdate command to update a Tablelist row.
| Syntax |
The syntax is partially free-form. The following rules apply:-
Note: For the purposes of documentation/examples the following is used:-
gpselect item ?options? ?parameters?
Examples:
To update row "3" of ".mytable" any of the following are valid:-
gpupdate .mytable -row 3 {{Column1} {Column2} {Column3}}
gpupdate -row .mytable 3 {{Column1} {Column2} {Column3}}
gpupdate .mytable 3 -row {{Column1} {Column2} {Column3}}
Some examples also using the "-focus" option:-
gpupdate .mytable -focus -row 3 {{Column1} {Column2} {Column3}}
gpupdate -focus -row .mytable 3 {{Column1} {Column2} {Column3}}
gpupdate .mytable 3 -row -focus {{Column1} {Column2} {Column3}}
gpupdate .mytable -row 3 -focus {{Column1} {Column2} {Column3}}
gpupdate .mytable -row -focus 3 {{Column1} {Column2} {Column3}}
When using gpupdate to match by column content where the content to match begins with "-" the "|" option can be used to turn off option processing. It is however recommended that the "|" option always be used to delimit column/value and column/match parameters (See below)
| Updating a Tablelist Row |
A Tablelist row can be updated in the following ways:-
Syntax:-
gpupdate item ?-focus? ?-select? data
gpupdate item ?-focus? ?-select? | column value
gpupdate item ?-focus? ?-select? -row row data
gpupdate item ?-focus? ?-select? -row row | column value
gpupdate item ?-focus? ?-select? | column match | data
gpupdate item ?-focus? ?-select? | column match | column value
For Example:
gpupdate .mytable {4 {Mary James} DT85241 5100.67}
...Will update the currently selected row in ".mytable" to contain the specified data.
gpupdate .mytable | name "John Doe"
...Will update the currently selected row in ".mytable" to set the value of the "name" column to "John Doe".
gpupdate .mytable -row 2 {4 {John Doe} DT85241 6500.99}
...Will update row "2" in ".mytable" to contain the specified data.
gpupdate .mytable -row 2 | name "John Doe"
Will update row "2" in ".mytable" to set the value of the "name" column to "John Doe".
gpupdate .mytable -select -row 2 | name "John Doe"
Will update row "2" in ".mytable" to set the value of the "name" column to "John Doe" and select the updated row..
gpupdate .mytable | name "Mary James" | {4 {John Doe} DT8524Z 5900.67}
...Will update the row in ".mytable" where the "name" column is "Mary James" to contain the specified data.
gpupdate .mytable | name "Mary James" | balance "123.45"
...Will update the row in ".mytable" where the "name" column is "Mary James" to set the value of the "balance" column to "123.45".
gpupdate .mytable -select | name "Mary James" | balance "123.45"
...Will update the row in ".mytable" where the "name" column is "Mary James" to set the value of the "balance" column to "123.45" and select the updated row.
| Using "-insertoptions" When Updating a Tablelist Row |
When updating Tablelist row where a column makes use of the -insertoptions option, "false" values should be specified.
For Example:
The following (Based on Tablelist Example 3) has the, optional, "false" values set...
gridplus tablelist .mytable \
-width 50 \
-height 8 \
-action double \
-insertexpr {%balance < 0} \
-insertoptions {{balance -fg red/black} \
{balance -selectforeground red/black}} \
-tableoptions stripe \
-relief groove \
-scroll y \
-selectfirst 1 \
-sortfirst 1 {
6 "Account" integer
0 "Name"
0 "SecurityCode" hide
6 "Balance" right real
}
...In this case "balance -fg red/black" sets the foreground colour of the "balance" column to "red" if the -insertexpr evalues to true -or- "black" if false. The same is also specified for the selected foreground colour.