Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): tableView row parent #13826

Merged
merged 5 commits into from
Nov 29, 2024
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 8, 2023

Split out of the "optimize tableview updates" PR to test it separately.

Will keep the click event when reassigning the data:

var menu = [];
var lab = Ti.UI.createLabel({text: "Row 0"});
var numrows = 0;

var self = Ti.UI.createWindow({title: "Table Test"});
var table = Ti.UI.createTableView({});

table.addEventListener("click", function(e) {
  console.log("Row " + e.index);
  lab.text = "Clicked " + e.index;
  menu[1].title = "Clicked " + e.index;
  if (e.index == numrows - 1)
    AddRows();
});

function AddRows() {
  var row = Ti.UI.createTableViewRow({title: "Row " + numrows});
  if (menu.length == 0)
    row.add(lab);
  menu.push(row);
  numrows++;
  var row = Ti.UI.createTableViewRow({title: "Row " + numrows});
  menu.push(row);
  numrows++;
  table.data = menu;
};

AddRows();
self.add(table);
self.open();

click on the last row to add more rows and then click on any row above it. The first row should update with the correct clicked number and there is a console output.

@m1ga m1ga marked this pull request as draft May 13, 2023 23:58
@m1ga m1ga marked this pull request as ready for review September 16, 2023 13:05
@hansemannn hansemannn merged commit 6fc9dcb into master Nov 29, 2024
6 checks passed
@hansemannn hansemannn deleted the 230508_androidFixTableParent branch November 29, 2024 08:45
@@ -190,6 +190,7 @@ private void appendRowInternal(Object rows, KrollDict animation, boolean interna
row.getProperties().getString(TiC.PROPERTY_FOOTER)));

// Add row to section.
row.setParent(section);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m1ga This is already done by section.add(row) in next call. I am not sure what it would fix :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the example code and you can see that it didn't use the event listeners when you reasign data to the table. section.add(row) is adding the row to the section, The PR is setting the parent to the row again. It looks like this is needed to get the event listener from the table again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants