Change Data of itab bound to CL_GUI_ALV_GRID programmatically and fire event DataChanged - event-handling

I'm currently facing the following problem:
In my abap program I am using an ALV grid to display a list of data.
Now I have got the requirement to convert the data of cell 5 depending on the value entered in cell 3. Normally I could just do this by implementing a handler method for the DataChanged or DataChangedFinished events.
But in my case the value of cell 3 is written into the backend table i connected to the alv grid when creating it via the method SET_TABLE_FOR_FIRST_DISPLAY. That means the alv does not register it when the data is changed. I also tried to use the method CHANGE_DATA_FROM_INSIDE of CL_GUI_ALV_GRID and this partly works if I set the value of VAL_DATA in the layout structure to 'X' when initializing the grid. The program runs through my handler for the DataChanged event.
But in my case it results in a short dump because the method can only work with caracter fields and I need cell 3 and cell 5 to be decimals. The dump is caused in the GET_CHANGED_DATA method of CL_GUI_ALV_GRID. When I am applying this mechanism to character fields it works fine.
This question refers to the following thread where I got the idea of setting the VAL_DATA flag of the layout structure from:
StackOverFlow Question
Did anyone ever face the same problem? Do you have any advice for me?

Related

Cursor Movement Cell to Cell Responsive Table

We have a requirement to move the cursor from one editable cell to another automatically in sap.m.table .
I tried all the previously answered blogs but none of the code works.
Has anyone tried similar requirement before ?
Thanks
Tisha
I had this requirement before. I had to automatically focus from input field in column A to the next input field in column C in my sap.m.Table.
How I solved it was like this:
I detected the change of my input A by defining an event handler on the view XML. Then I get by id the input C and use jQuery method to put focus on its HTML inner element.

Link editable field to a certain cell in table figure in MATLAB app designer

I am building an application in MATLAB app designer (2019b), and I am trying to link two blank fields to a table that has only two columns, such that the first field should show the first value (in the first column) in the table and the other should show the last value in the first column in the table.
Example
table:
9 2
3 4
5 6
blank field_1: 9
blank field_2: 5
I am a C++ person, so whenever I am developing, for instance in SFML, I just have one event loop that captures and updates everything - no matter where I press on the window, but, in MATLAB, whenever I press a button - I need to build a separate callback function. Here, I am not calling back anything - I just need to update the value.
Anyone, please help?
Thank you
Here's an example which illustrates how you can achieve the behavior you want.
In the below example, I am creating a uitable in the App startup, and I am defining a callback which updates the table as required when the cells are modified.
function startupFcn(app)
vars = {9,2;3,4;5,6;'blank _field_1:', '';'blank field_2:', ''};
t = uitable(app.UIFigure,'Data',vars);
t.ColumnEditable = true;
t.DisplayDataChangedFcn = #updateTable;
function updateTable(src,~)
src.Data(end-1:end,2:end) = [src.Data(1,1) src.Data(end-2,1)].';
end
end

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?

Getting selected cell indices from uitable

I have a uitable with 10 columns, which I'm populating from a db.
Now I want to know when the user choose a specific row. For example if the user chooses the 3rd record, I would like to get back the value 3, so then I could access the actual information to for example open that specific record from the path.
I found online that I would need findjobj.
I also think that the method should be implemented in here:
function uitable_CellSelectionCallback(hObject, eventdata, handles)
However I found a little information about how I should proceed.
Anyone had this problem or knows how to solve it?
When calling the CellSelectionCallback you can access the Indices property, which is a 2 x 1 array containing the row and column indices of the cell you have selected.
Therefore in your callback, use something like this:
row = eventdata.Indices(1)
col = eventdata.Indices(2)
and that should get you going.
In order to avoid callbacks, you can use app.UITable.Selection in the newer versions of MATLAB where app is your app object and UITable your uitable name

DataGridViewComboBoxCell selectioindexchange event

I have a data-grid and three column in it. one column is type of DataGridViewComboBoxCell, three items are in this grid combo box, now i have to invoke selection index changed event to change value according to combo value change in grid.
also help me to make a new event ....
please help...
thanks
I really can't understand your question.
But maybe these informations can help:
A ComboBoxColumn has always two kinds of controls. A presenting one (in most cases a label) which is individually for each row. And a editing one that will be shared for the whole column. So take a look into this documentation and the IDataGridViewEditingControl Interface.
Maybe these will give you a starting point on how to solve your problem.
In the Load event for the form, you need to get the cell that you want to add the handler to and cast it as a regular combo box. You can then add the event handler on SelectedIndexChanged, but it must be done programmatically, and depending on the language you are using.