How to store all values from cells i have edited in uitable.
1 view (last 30 days)
Show older comments
Darren Koh
on 19 Feb 2018
Commented: Darren Koh
on 21 Feb 2018
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
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)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!