How to refresh data grid without using unview?
Is it possible in the following code to update the grid displayed in g/pane face without using unview?
I am trying to eliminate the flicker resulting from unview. Would it be possible to update the g face without redisplaying the entire view ?
x: copy  for i 1 179 1 [append x reduce [i random 'abcd']]
update: does [q: copy  foreach face g/pane/pane [append q face/text]]
do qq: [grid: copy [across space 0]
forskip x 2 [append grid compose [
field (form x/1) 40 edge none
field (form x/2) 260 edge [size: 1x1] return
view center-face gui: layout [across space 0
g: box 300x290 with [pane: layout/tight grid pane/offset: 0x0]
slider 16x290 [g/pane/offset/y: g/size/y - g/pane/size/y * value show g ]
return btn 'Add' [
row: (to-integer request-text/title 'Insert at Row #:') * 2 - 1
update insert at q row ['' ''] x: copy q unview do qq
btn 'Remove' [
row: (to-integer request-text/title 'Row # to delete:') * 2 - 1
update remove/part (at q row) 2 x: copy q unview do qq
btn 'Col 1' [update editor extract q 2]
btn 'Col 2' [update editor extract/index q 2 2]
btn 'Save' [update save to-file request-file/save q]
btn 'Load' [x: load to-file request-file do qq]
btn 'History' [
m: copy 'ITEMS YOU'VE EDITED:^/^/' update for i 1 (length? q) 1 [
if (to-string pick x i) <> (to-string pick q i) [
append m rejoin [pick x i ' ' pick q i newline]
] editor m
posted by: OneArb 5-Mar-2017/15:38:08-8:00
Take a look at http://re-bol.com/grid3.r
BTW, that link is from a much older tutorial. I prefer to send people to http://business-programming.com
posted by: Nick 5-Mar-2017/18:20:55-8:00
A couple more scripts which demonstrate the same basic update technique for created grids (grids created from widgets in a generated layout):
(actually, those are both the same script, just reformatted)
posted by: Nick 6-Mar-2017/11:55:31-8:00
A full line-by-line explanation of the above example is available at:
posted by: Nick 6-Mar-2017/15:26:15-8:00
Those little generated grid examples are useful when you want to create interesting layouts to handle small blocks of data. The 'list' style is best suited to handle larger blocks (thousands to millions of values):
R E B O L [title: "Data Grid Library Example"]
headers: ["Column1" "Column2"]
x: data: [
["Item 01-01" "Item 02-01"]
["Item 01-02" "Item 02-02"]
["Item 01-03" "Item 02-03"]
["Item 01-04" "Item 02-04"]
["Item 01-05" "Item 02-05"]
Decompress and take a look at that gridlib.r script.
posted by: Nick 5-Mar-2017/18:25:29-8:00
Take a look at:
for more examples of the list style (the native 'grid' widget in VID).
posted by: Nick 8-Mar-2017/10:09:46-8:00
In the 3 scripts above, in the beginning line which generates the random rows of values, you can increase the number of repeats to several millions, to see that no performance is lost in scrolling or displaying data in the list widget (I've tested the list style with 30 million values (10 million rows of 3 columns), and there is absolutely no slow down in the display performance). Of course searching, sorting, etc., is slower with huge blocks of data, but the performance of the display is fast. For big databases, it's far better to use that list widget than grids which are generated from large numbers of faces.
posted by: Nick 8-Mar-2017/22:17:37-8:00
Here's a version of the crudgrid.r example above, using the list widget, instead of a generated layout:
posted by: Nick 9-Mar-2017/9:46:26-8:00
Thanks for all the examples. The commented code was welcome.
I am trying to add faces at runtime inside a list.
I posted a code sample of what I am trying to achieve.
posted by: OneArb 15-Mar-2017/18:33:42-7:00
There's a commented example of list widget:
and a more nicely duplicate of it in this tutorial:
posted by: Nick 18-Mar-2017/21:16:14-7:00