DevExpress XtraGrid bound to List<T> : how to show change in data immediately in the GUI? - devexpress-windows-ui

I have an XtraGrid and a VerticalGrid on the form. Both are bound to the same List<T>.
The XtraGrid is like a navigator. Here's a hypothetical example; ignore the specific use case:
OrderId|OrderDate|DateShipped
123| 2017-05-01|<null> <- assume this is the focused row
456| 2017-05-02|2017-05-04
and the VerticalGrid displays the OrderDetail:
OrderId
OrderDate
Item
Price
DateShipped
When DateShipped is changed in the VerticalGrid, the underlying item in the List<T> is updated; however, the XtraGrid does not visibly reflect the change until focus leaves the row: an order-date for OrderId 123 doesn't appear in the XtraGrid filling the <null> cell until focus in the XtraGrid moves to the next row (by the user clicking on it or using keyboard).
Is there a setting in the XtraGrid that causes it to be immediately refreshed when a property in the bound object is changed?

Sorry for the late answer but what you are searching is the method RefreshData() of the active grid view (not the grid control itself) or - if you know the row handle: RefreshRow(rowHandle)

Related

Adding Listener for TreeViewerColumn

I have a treeviewer with dynamic number of columns. I am using ColumnLabelProvider. Every column cell is populated with a image (not text) using getImage() method of labelProvider.
I need a listener that will be triggered when i double click on column cell and an editor should be opened upon double click. I tried using selection listener for tree column but that doesn't work.
My tree item already has a listener that performs another operation so this listener that i add for column should be independent of it. This is the reason
i didnt create my tree using SWT.FULL_SELECTION because if i use full selection the operation intended for my tree item is performed though i double click the column cell.

NSTableView with custom cell view and NSArrayController bindings drawing a blank string

It took me forever to figure out how to set up editing on a custom cell view for an NSTableView. Thanks to StackOverflow I figured that much out. P.S. I was doing all of this in Interface Builder.
I have a single column table in which the cell is a custom multi-control NSTableCellView, with:
name (in bold)
description
detail
It's all text. Set up editability on the name only. The table is sorted by the name.
When I edit the name, it has the effect on the bound model that I expect. The table even re-sorts correctly. However, it's displaying incorrectly. The description and detail (not editable) still show up correctly, but the name (which was edited) is a blank. When I inspect the model, it has the correct updated value. But the cell view itself is incorrect.
This doesn't happen all the time--it typically happens if the cell is re-sorted to the top or bottom of the table, but that may be a red herring and may instead have to do with NSTableView cell caching or something.
I hacked up a workaround in which I assign a delegate to the NSTextField (automatically generated for the NSTableCellView) and intercept the textShouldEndEditing event. For some reason this event is getting triggered twice for a given edit (after I press "enter" in the text field)--once for the actual edit where fieldEditor.string is different from the model name, followed by another event where fieldEditor.string is the same as the model name. If I return false for my textShouldEndEditing handler in the latter case, then the cell contents end up being drawn correctly. That's the hack.
I feel like I'm doing something wrong here though, and that shouldn't be necessary.
Is the textShouldEndEditing event supposed to be fired twice?

Preserve the scroll position of a Page

I have a page with many elements (forms and tables)
When I want add a row in a table I scroll the page to the table, I press a button to add a row, edit the info in a popup and press OK.
Then I insert the new row in the model and refresh() the model.
At this point the page auto scroll at the top, but I don't want this behavior!
I want that the page stay in the same Y position!
I see that sap.m.page has scrollTo function https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Page.html#scrollTo
but I don't know how take the position before the refresh()
The Page does unfortunately not have an API to get the current scroll position, but the idea is a good one we consider.
As a workaround you could access some private method of the Page - but only if you accept the risk that it breaks with a future version of UI5:
page.getScrollDelegate().getScrollTop()
To make it safer you should verify both methods exist before calling them and also check the returned value for plausibility. Then you are pretty safe that in the worst case it will again scroll to the top in some future UI5 version.
you have to fill the iTime parameter in scrollTo function - e.g. srollTo(100, 1) - then it works
using 0 for iTime does not work

Check if a record is selected from a dataPointGrid

I have a dataPointGrid and I want to check if a record from it is being selected (mouse clicked on)
Data point grid above. I want to check if a folder (record) is being selected.
Is there a method that does this?
Add ListGrid#addSelectionChangedHandler() on list grid that is called when (row-based) selection changes within this grid. Note this method fires for each record for which selection is modified - so when a user clicks inside a grid this method will typically fire twice (once for the old record being deselected, and once for the new record being selected).
Look at the ListGrid#setSelectionType() as well that defines a listGrid's clickable-selection behavior (MULTIPLE, SINGLE, SIMPLE or NONE)

GWT: Multi Selection model does not update the celltable status in some cases

I am using the GWT MultiSelectionModel within a CellTable in which I have a checkbox in one column and a widget in the other column. I have added handlers to update the selection status based on user clicks. If the user clicks on any part of either columns when the cell is selected, the status gets updated correctly and the cell turns white from light blue. Howvever, If the user clicks on the check box and the cell is selected, the check box gets unchecked but the cell is still blue. Even more strange: This issue does not happen if I have a few breakpoints before the status update code is executed.
In all other cases, the cell state and the checkbox state gets updated correctly. Note that I am not using the ProvidesKeys interface since the object do not change.
Can anyone help me with this? Thanks for your help.
Have you tried using a CheckBoxCell for your checkbox column and, specifically, the CheckboxCell(boolean dependsOnSelection, boolean handlesSelection) constructor (by passing true to both params)?
I've got almost the same problem when I use MultiSelectionModel. What's my walkaround is to see the checkbox's column as a special one and then to deal with it manually. Say:
myDataGrid.addCellPreviewHandler(
#Override
public void onCellPreview(final CellPreviewEvent<MyCellData> event){
if("click".equals(event.getNativeEvent().getType()) && 0 != event.getColumn()){
doWhatYouWant();
}
}
)