From 9fb00958219e16362dde72a2eca84eee70b9d79a Mon Sep 17 00:00:00 2001 From: Stephan Wald Date: Tue, 13 Nov 2018 15:18:33 +0100 Subject: [PATCH] retain the column setup if the structure of the data is not changed --- BBjGridExWidget.bbj | 25 ++++++++++++++++++++++--- Demo/GridColumnStateDemo.bbj | 6 ++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/BBjGridExWidget.bbj b/BBjGridExWidget.bbj index ea6301cb..39877fc8 100644 --- a/BBjGridExWidget.bbj +++ b/BBjGridExWidget.bbj @@ -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 */ @@ -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 @@ -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() @@ -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) diff --git a/Demo/GridColumnStateDemo.bbj b/Demo/GridColumnStateDemo.bbj index ec4f52e4..928b7866 100644 --- a/Demo/GridColumnStateDemo.bbj +++ b/Demo/GridColumnStateDemo.bbj @@ -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 @@ -84,6 +86,10 @@ setState: fi return +refresh: + grid!.setData(rs!) +return + onWinKeypress: declare auto BBjKeypressEvent key_ev! key_ev! = BBjAPI().getLastEvent()