In App Designer. Does anyone know how to add rows in a Table every time you push a button?

조회 수: 11 (최근 30일)
function ButtonPushed(app, event)
app.UITable.Data = {'Value after first click'};
?????????????????
end

답변 (1개)

Tony Mohan Varghese
Tony Mohan Varghese 2018년 3월 22일
Assuming that there are 4 columns in the UITable, you can append the data to the table by using the following example code.
% Button pushed function: Button
function ButtonPushed(app, event)
newData = {1 2 3 4}; %sample data for each column
app.UITable.Data = [{app.UITable.Data{:}};newData];
end
newData corresponds to the data that you want to add.
  댓글 수: 2
JClarcq
JClarcq 2018년 4월 4일
편집: JClarcq 2018년 4월 4일
Previous answer does not work for a numeric table. Here is a working example to add/remove rows with push button event for numeric table:
% Button pushed function: btnAddCycle
function btnAddCycleButtonPushed(app, event)
newData=[0 0 0];
% Add 1 row to table
app.CycleTable.Data = [app.CycleTable.Data;newData];
% Update data component
app.data.LoadCycle=app.CycleTable.Data;
end
% Button pushed function: btnRemoveCycle
function btnRemoveCycleButtonPushed(app, event)
% remove last row of table
app.CycleTable.Data(end,:)=[];
% Update data component
app.data.LoadCycle=app.CycleTable.Data;
end
madhura patil
madhura patil 2019년 4월 3일
May i know what excatly is Cycle table and LoadCycle here?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by