Skip to content

Commit

Permalink
retain the column setup if the structure of the data is not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Wald committed Nov 13, 2018
1 parent 976790e commit 9fb0095
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 22 additions & 3 deletions BBjGridExWidget.bbj
Expand Up @@ -383,6 +383,7 @@ class public BBjGridExWidget extends BBjWidget
field private BBjNumber Editing! = 0
field private HashMap ColumnGroups! = new HashMap()
field public static BBjNumber Debug=0
field private BBjString DataFingerprint$
rem /**
rem * disabled default constructor
rem */
Expand Down Expand Up @@ -604,12 +605,26 @@ class public BBjGridExWidget extends BBjWidget
fi
wend
fi

rem if the data fed to the grid is the same as before, it's an update.
rem In this case we want to retain the setting of the columns
rem and the order and sizes
r1! = rs!.getItem(0)
datafingerprint$ = r1!.getFieldNames().toString()
keep=0
if (datafingerprint$ = #DataFingerprint$) then
tmpstate!=#getColumnState()
fi

#RS!.createIndex()
#TREE! = null()
#URL$=""
#SelectedRowsMap!.clear()
#performGridDataUpdate()
if tmpstate!<>null() then
#setColumnState(tmpstate!)
fi
#DataFingerprint$ = datafingerprint$
methodend
rem /**
rem * set the data into the grid
Expand Down Expand Up @@ -1451,8 +1466,13 @@ class public BBjGridExWidget extends BBjWidget
method public void addColumnGroup(BBjString id$ , BBjString name$, BBjVector columns!)
#addColumnGroup(id$,name$ , columns! , 1 , "" )
methodend


rem /**
rem * Set an image list for a given column
rem * The column has to contain the values "1","2","3" to x to reference
rem * the slices in the BBjImage list
rem * @param BBjString colname$: the column name
rem * @param BBjImage imagelist!: the image list containing the image sprites
rem */
method public void setColumnImageList(BBjString colname$, BBjImage imagelist!)
enc! = java.util.Base64.getEncoder()
list! = new JsonObject()
Expand All @@ -1466,7 +1486,6 @@ class public BBjGridExWidget extends BBjWidget
#AdditionalAttributes!.setFieldAttribute(colname$,"TYPE",#GRID_TYPE_BASIC_IMAGE())
#AdditionalAttributes!.setFieldAttribute(colname$,"IMAGES_LIST",list!.toString())
methodend

rem /**
rem * experimental function that shows the developer console
rem * (only in GUI, for BUI it's a NOOP)
Expand Down
6 changes: 6 additions & 0 deletions Demo/GridColumnStateDemo.bbj
Expand Up @@ -24,9 +24,11 @@ fi

tb_get! = wnd!.addButton(300,10,3,200,25,"GET STATE")
tb_set! = wnd!.addButton(301,230,3,200,25,"SET STATE")
tb_refresh! = wnd!.addButton(302,450,3,200,25,"REFRESH")

tb_get!.setCallback(BBjAPI.ON_BUTTON_PUSH,"getState")
tb_set!.setCallback(BBjAPI.ON_BUTTON_PUSH,"setState")
tb_refresh!.setCallback(BBjAPI.ON_BUTTON_PUSH,"refresh")

gosub fillGrid

Expand Down Expand Up @@ -84,6 +86,10 @@ setState:
fi
return

refresh:
grid!.setData(rs!)
return

onWinKeypress:
declare auto BBjKeypressEvent key_ev!
key_ev! = BBjAPI().getLastEvent()
Expand Down

0 comments on commit 9fb0095

Please sign in to comment.