How to store all values from cells i have edited in uitable.

2 views (last 30 days)
This part of the code refreshes everytime a cell is edited so the whole of handles.storedvals is overwritten, thus only displaying the value of the most recently edited cell. Is there a way to hold the values of all cells that were edited?
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
data = get(hObject, 'Data');
indices = eventdata.Indices;
r = indices(:,1);
c = indices(:,2);
linear_index = sub2ind(size(data),r,c);
storedvals(linear_index) = data(linear_index);
handles.storedvals = storedvals;
guidata(hObject, handles);

Accepted Answer

Walter Roberson
Walter Roberson on 19 Feb 2018
Before
storedvals(linear_index) = data(linear_index);
do
if isfield(handles, 'storedvals')
storedvals = handles.storedvals;
else
storedvals = nan(1, numel(data));
end

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!