Uitable: deleting row selected problem

7 次查看(过去 30 天)
David
David 2013-8-4
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 个评论
David
David 2013-8-4
编辑:Azzi Abdelmalek 2013-8-4
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 2013-8-4
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. :)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by