App Developer: delete table rows

조회 수: 7 (최근 30일)
William Gaillard
William Gaillard 2019년 3월 6일
댓글: Jorge Torres 2020년 4월 19일
There are lots of questions and answers for how to delete table rows in Matlab, but none of the solutions work very well in Matlab App Developer. In my app I have a table that is populated with data entered with pushbuttons and edit field boxes. When data is entered into the table, the table grows in size by 1 row. All of that works just fine.
I want a pushbutton that will reset the table to its default size of no rows. To achieve this I created a pushbutton called "Clear" and the following code:
% Button pushed function: ClearButton
function ClearButtonPushed(app, event)
app.UITable.Data =[];
end
Undesirablly, this code will replace all the data in the table with zeros. After entering new data into the table, instead of appearing on the first row, the new data will appear after all the zero rows. I have attached pictures for clarificaiton. The image on the left is before hitting the clear button. The image on the right is after hitting the clear button and then entering new data for one row. I would like for the image on the right to have only one row with the new data and no zero rows.
Similarly, I would like to click on one row and then press a "delete" pushbutton to delete only that specific row. For example looking at the image on the right, the 1st column numbers are 1, 2, 3, 1. If I click on the row with the 3 then I want the sequence for the frist column to appear as 1, 2, 1 with no zero row between the 2 and the second 1.

채택된 답변

William Gaillard
William Gaillard 2019년 3월 6일
Ah, of course I solve my problem shortly after posting the question. Because I have multiple ways to enter data into the table I need a variable that keeps up with the current row so that I don't overwrite data. I just added a line after app.UITable.Data =[];
that resets the row number to 1.
  댓글 수: 1
Jorge Torres
Jorge Torres 2020년 4월 19일
Can I see your code, please?.
Currently I would like to delete a selected row from a table using a "delete button", but I don`t now how exactly.
Thanks.

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

추가 답변 (2개)

William Gaillard
William Gaillard 2019년 3월 6일
Forgot to attach the image. Here it is

William Gaillard
William Gaillard 2019년 3월 6일
cleartable.jpg
I guess it is easier if I attach it this way :)

카테고리

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