Uitable: deleting row selected problem

2 views (last 30 days)
David
David on 4 Aug 2013
Hi mates
I am having trouble when deleting a selected row in a uitable. My problem is that if i delete the last row, when i reinitialize the table it says the index is out of bounds, as the previous selection is not erased. My question would how to change the user selection once i have deleted the row.
Thanks you in advance
  3 Comments
David
David on 4 Aug 2013
Edited: Azzi Abdelmalek on 4 Aug 2013
This is the callback of the cell Selection, nothing special
% --- Executes when selected cell(s) is changed in uitableTodosSetup.
function uitableTodosSetup_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to uitableTodosSetup (see GCBO)
% eventdata structure with the following fields (see UITABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
indices=eventdata.Indices;
handles.editSetupColumnaSeleccionada=indices(2);
guidata(hObject, handles);
And then if you push the Delete button:
% --- Executes on button press in pushbuttonEditarSetupEliminar.
function pushbuttonEditarSetupEliminar_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonEditarSetupEliminar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tableModelPanelEditarSetup=TableModelPanelEditarSetup();
tableModelPanelEditarSetup.eliminarSetup(handles.editSetupColumnaSeleccionada,handles.coche,handles.uitableTodosSetup);
%Actualizo el coche seleccionado
cocheDAO=CocheDAO();
handles.coche=cocheDAO.buscarPorId(get(handles.coche,'id'));
guidata(hObject,handles);
I think it is more useful the description rather the code itself.
dpb
dpb on 4 Aug 2013
Reformat the code to be legible...then the code will be useful. :)
It takes code to see what actually is going on; descriptions of intent are valuable for context but rarely are sufficient to diagnose a problem. Among the most important of the reasons why is that if the person w/ the problem understood the problem well enough to describe it in sufficient precision as to allow the solution then they could solve it themselves 'cuz there wouldn't be a problem. :)

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements 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!