How to use inline editor of DataGrid without editorBuffered

i want use inline editor of DataGrid that editorBuffered is false,
i creat a addItemPropertyChangeListener to commit data ,but it’s wrong

Hi,

Could you describe in more details what problem do you face?

Regards,
Gleb

i have a DataGrid,
editorBuffered is false,
so i have not ok button to save data ,
i want save data after a Property changed,
i creat a addItemPropertyChangeListener to save data ,i don’t commit;

colorGroupsDs.addItemPropertyChangeListener(e -> {
  			if (null == e.getItem().getStyle()) {
  				e.getItem().setStyle(style);
  			}
  //			colorGroupService.insertColorGroup(e.getItem());
  			colorGroupsDs.commit();
  		});

when i use colorGroupsDs.commit(); it will alert Access Denied,
when i use colorGroupService.insertColorGroup(e.getItem()); and insert a new data ,it save twice and throw a SQLServerException
SQLServerException: 违反了 PRIMARY KEY 约束 'PK__SAMPLEOR__3214EC27147C05D0'。不能在对象 'dbo.SAMPLEORDERSHEET_COLOR_GROUP' 中插入重复键。

And what exactly goes wrong? The listener doesn’t fires or commit fails?

when i inser a new data, It looks like it was submitted multiple times%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20180730155722

this is insert service

@Override
public void insertColorGroup(ColorGroup c) {
dataManager.commit(new CommitContext( c ));
}

%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20180730155535
this is entity

colorGroupsDs.commit() is enough to commit changed data. Could you provide the Access Denied exception message?

16:03:19.379 ERROR c.h.cuba.core.sys.ServiceInterceptor - Exception in DataService.commit(…): com.haulmont.cuba.core.global.RowLevelSecurityException: Could not read security token from entity com.artwell.sampleordersheet.entity.ColorGroup-3104 [detached], even though there are active attribute access for the entity.
16:03:19.394 ERROR com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaTextField: com.haulmont.cuba.core.global.RowLevelSecurityException: Could not read security token from entity com.artwell.sampleordersheet.entity.ColorGroup-3104 [detached], even though there are active attribute access for the entity.

%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20180730160327

my cuba version 6.8,

Unfortunately, I can’t reproduce the problem. Could you please attach a sample project which reproduces the problem?

this is a test project , you can open “ColorGroup Browse” to add a data ,please select a “color” then input “qty”,
you will get a Exception,the Exception like colorGroupService.insertColorGroup(e.getItem());
Test.rar (9.1 MB)

i delete ColorGroup entity and recreate,
It doesn’t have Access Denied anymore,
but new Exception be alerted
%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20180730180217
the Exception can reproduced in test.rar

So after an investigation, I’ve created a GitHub issue. For now, I can suggest using either buffered editor and commit in the EditorPostCommitListener or call a commit by a button.

1 Like

i haved created my owen commit

another problem:%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20180731165536
this is a datagrid ,the column’s of “合计” editable is false ,i want edit other column and the “合计” is changed auto,
so What’s the way to do it

Take a look at this demo project.

1 Like