Extra newline in WebViewer

I want to get rid of a newline that is thrown at the bottom of my WebViewer list. It messes the sorting functionality totally. And if I click the newline row, I get an error: "Select list item: list item too large. Attampt to get item number 3 of a list of length 2".

So the main issue is: which of the these is causing the extra newline (/n)?
Is it the php or app code or the table.html?

The app fetches lines from DB with php script select_project_v3.php, which basically includes the followings (note newline \n at the end):
$sql = "SELECT project_id, name, crea_date FROM PRIF_PROJECT1";
while($row = $result->fetch_assoc()) {
echo $row["project_id"] . "," . $row["name"] . "," . $row["crea_date"] . "\n";

The app code slice is here:

The table.html is finally adding the rows to WebViewer element:

var delimiter = ",";

// get the table to display from the window.AppInventor object and split at new line
var urlArray = window.AppInventor.getWebViewString().split("\n");
//var urlArray = location.search.slice(1).split("/n");

var doc = document;
var fragment = doc.createDocumentFragment();
var thead = doc.createElement("thead");
var tr = doc.createElement("tr");

// split at delimiter
var rowArray = urlArray[0].split(delimiter);

addRow(thead, "th");

var tbody = doc.createElement("tbody");
  var tr = doc.createElement("tr");

  // split at delimiter
  var rowArray = urlArray[i].split(delimiter);

  tr.addEventListener ("click", function () {
    // return index (add 1 because first row is the header row)
    //window.document.title = this.rowIndex + 1;
    window.AppInventor.setWebViewString(this.rowIndex + 1);

  addRow(tbody, "td");
var table = doc.createElement("table");

// http://stackoverflow.com/a/9236195/1545993
doc.getElementById("myTable").getElementsByTagName('table')[0].className = "striped";

function addRow(dom, tag) {
    var el = doc.createElement(tag);
    el.innerHTML = rowArray[j];

Have you tried removing the last "\n" from your responseContent ?

If you show what comes back in responseContent (just the last part) it might make it easier to find a solution

this is answered in the Q&A section oft that page you copied the example from, see Q4 here App Inventor Tutorials and Examples: Dynamic Table Layout | Pura Vida Apps

PS: btw. it would be nice to link to the source next time... this is how the internet works... thank you...

Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Yes I have tried that. It actually does not work without the "\n" which is echoed in the php script.

Using Taifun's example table.aia, i have added an "\n" to the end of the csvTable
This shows the extra row

Then remove it with the segment text block and it goes away

1 Like

Thank you all , it worked :slight_smile:

  • Tommi S.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.