Setting Record Data resets ToggleButton - grid

I am facing a strange problem.
I have created a normal ext-gwt grid with two columns. One column displays a number and the other renders a ToggleButton. As soon as the ToggleButton gets pressed a small window appears with: 1- a textfield (to enter a number), 2- an ok button.
When the ok button is pressed the column containing the number should change it's value to the value given in the small window's textfield. This is the final picture I want to have. Easy! right?
The problem comes now. This is what is executed when the ok button is pressed in order to change the value in the column:
Integer value = new Integer(10);
Record record = store.getRecord(bean);
record.set("employeeNumber", value);
Although the value is actually changed using this code, it makes something weird. The ToggleButton remains in the "un-pressed" state whenever this code is executed. If I remove the last line, the ToggleButton functions normally again (gets pressed).
Any idea how to solve the problem of the ToggleButton?
Thank you

So you want the toggle button to change state after setting the value, right?
How do you get the toggle button into the grid?
I assume by using a custom widget renderer? In this case the render(..) method will be called more than once, returning a fresh and un-toggled button each time which will be displayed...
Maybe you could post some more code...?

Related

QML ComboBox not saving selection

I have an issue similar to this post: https://forum.qt.io/topic/88519/editable-combobox-not-saving-edited-text/2
Where after I make a selection in the dropdown, if I scroll out of view and then back into view, the selection reverts back to the previous selection. I have these combo boxes in a scrollable TableView which apparently reloads elements every time they come back into view. Also, my ComboBox is not editable but I just want to be able to save the new selection I make.
I know I need to handle onAccepted, but I am not sure how to save the new value I select into the current selection that gets displayed if I leave the view then come back to it. I have 2 methods like this:
onDisplayTextChanged: {
console.log("currentText in onDisplayTextChanged: " + currentText)
onAccepted()
}
onAccepted: {
console.log("currentText in onAccepted: " + currentText)
}
I use onDisplayTextChanged to receive the new value selected that I can pass to a Python 3 script in the future, before calling onAccepted because onAccepted does not trigger for some reason after I click on a new selection. This is definitely not preferable for me though.

Tooltip becomes broken after editing value in the grid's cell - ExtJS6

We have encountered a subtle issue with ExtJS grid.
It is quite regular grid with standard 'cell editor' plugin and two editable columns (having at least two is important).
Once an editable cell is submitted, the store backing the grid gets reloaded.
However grid reload takes place in a subsequent time slot because it's a part of asynchrouous task completion.
All this works well unless the user submits editable cell with the Tab key rather than with Enter. Tab makes second column's cell editor visible and shifts input focus there. After that the store reloads, or at least I believe it happens afterwards.
At first glance nothing bad happens to the UI, it continues working as usual. However after some time an attempt to hover the mouse over any element to which a tooltip is attached causes crash and console gets flooded with errors.
We've been able to establish immediate reason of this: garbage collection cycle that follows grid reload treats the input field belonging to the second column's editor as garbage. As a result Ext.Element instance wrapping this field has its dom property erased. By itself it's seemingly not an issue. However, for some reason, when it comes to show a tooltip, the system tries to get its hands on the Element that was previously garbage collected. Strangely enough, that element has nothing to do with tooltips.
In order to reproduce this open the fiddle and then
Double-click any cell in the first column to make it editable
Type any value
Press Tab on the keyboard
Wait 30 seconds
Move and hover the mouse over the grid cells to view tooltips
It does not need to be a grid tooltip, the bug equally occurs even if the mouse hovering over any unrelated UI element with tooltips.
So the question is: how can it be that garbage-collected element is reused, and how to correct this?

JavaFX uneditable combobox - strange reaction on DELETE keystroke

Preamble
I have uneditable combobox (user can select from list, but can't type). I suppose, when user have focus on it and press DELETE, it's selection must be cleared? It seems that it is (screenshot was made when I selected some value and then pressed DELETE):
selectionModel is null - screenshot
Problem
But UI control still shows old value, it wasn't cleared. Also ValueChanged listener wasn't triggered.
How to cause
Create ComboBox and fill it with some values. Select any value. You already have selection on it, but it's not enough - now DELETE pressing won't even clear selectionModel. The same with selecting by TAB. Select it with double click (expand and collapse) and then press DELETE. Now selectionModel must be cleared, but UI still show your value.
Another thing: if you closed ComboBox, pressing DELETE will trigger ValueChanged listener. Pressing DELETE on expanded ComboBox won't trigger it, but nevertheless value will become null.
Did anybody face with this? Any ideas to make it work naturally i.e. clear selectionModel and update UI?
Well, the problem was not exactly where I thought. "Delete" button did nothing in any case, ComboBox was cleared because it's items list was refreshed every time when it was expanded -> old items were deleted including selected. Problem was the same - UI wasn't updated. So I resolved this by adding ComboBox.getEditor().clear() before refreshing it's items list in onShowing event.

How to figure out the index of a ToggleGroup's selected toggle?

I'm trying to select an item from a list that's sorted the same way as a ToggleGroup I have besides it. However, I found that toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle()) always returns -1 (visible in the IndexOutOfBoundsException thrown as I pass it). Is there another way of figuring out the index, or am I at a loss with my approach and need to figure out something completely different?
UPDATE: Apparently, for the first time an item is selected (I have this code attached to changes of selectedToggleProperty()), it works fine (I just get no notice of it because the elements I make visible have no proper layout). However, when an item is selected while another item already is selected, getselectedToggle() becomes null, causing aforementioned behavior.
All of the JavaFX toggle controls have a property called UserData. You should use that to create the links between the toggles and data list. Relying on the index of the toggles in the toggle group is probably a bad idea.

How to make a button when pressed to do a certain thing on another screen Appinventor

I would like a button when pressed to do a certain thing on another screen. For example if I had 2 buttons on screen1, and when you click either of the buttons it opens another screen, however depending on which button clicked it will display a certain component.
You can use these two blocks to do that. When two buttons are pressed, they both open the same screen, but they have different start values. Then, on the other screen, you can use the get start value block to find out what value you got, to figure out which button was pressed.
Solution 1:
You can use two separate activities for separate components.
or
Solution 2:
Pass your button position as putExtra from first screen.
Intent i=new Intent(getApplicationContext(), NextActivity.class);
i.putExtra("btn_position",position); //pass your button positon as int
startActivity(i);
And get the your button position using getExtra from second screen.
Intent intent = getIntent();
int button_postion = intent.getIntExtra("position", 0);

Categories

Resources