how to activate/deactivate some boxes of iutable depending on the entry in the first box

hi everybody,
I have the following iutable,
is it possible to deactivate (make it uneditable) boxes A for exemple when typ is "1" and box B, C when typ is "0" by clicking on the button "set" ?
the button save :
function save_Callback(hObject, eventdata, handles) data = get(handles.uitable1, 'data'); disp(data)
since I set the boxes as editable boxes in the inspector property.
thank you

 Respuesta aceptada

3 comentarios

Thanks, this is how I wrote the code(it may help someone)
% --- Executes on button press in set.
function set_Callback(hObject, eventdata, handles)
data = get(handles.uitable1, 'data');
[m,n]=size(data);
for i= 1:m
if data(i,1)==0
for k=2:4
data(i,2)=0;
data(i,3)=0;
end
end
if data(i,1)==1
for k=2:4
data(i,4)=0;
end
end
end
set(handles.uitable1, 'data', data);
data
there is certainly a way to get it shorter, is there not ?
I do not see how this code achieves what you want. You are just setting the values to zero and not making it uneditable. This can also be achieved without for loops and it is not at all clear what you are trying to achieve with the k-loop as this k is not used inside the loop. This is the correct code to do this:
function set_Callback(hObject,eventdata,handles)
data = get(handles.uitable1,'data')
idx = (data(:,1) == 0);
data(idx,2:3) =0;
data(~idx,4) = 0;
set(handles.uitbale1,'data',data);
Paul Nanfah
Paul Nanfah el 17 de Jun. de 2015
Editada: Paul Nanfah el 17 de Jun. de 2015
k loop ist useless indeed since I dont need to run through the row,also I am quit satisfied with setting the values to zeros! thanks again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Install Products en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Jun. de 2015

Editada:

el 17 de Jun. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by