Could not execute error when deleting all rows in WebListBox

I have a Container Control with 1 WebListBox that I use for multiple lists. When I click one of the buttons in the tool bar, I get the following error only ONCE then it behaves just fine. Any ideas?

[quote]Could not execute returned javascript: Index or size is negative or greater than the allowed amount
Source: Xojo.controls[‘EUJVLVT6’].deleteAllRows();[/quote]

Do me a favor and when you get that error the next time, click in the error box and do a Select All instead of manually selecting the text. What you’ve got there is only the first line of the offending code.

Could not execute returned javascript: Index or size is negative or greater than the allowed amount
Source: Xojo.controls[‘XNSVsL7y’].deleteAllRows();
Xojo.controls[‘XNSVsL7y’].setColumnCount(5);
Xojo.controls[‘XNSVsL7y’].setColumnWidths(‘20%,20%,20%,20%,20%’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(0,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(1,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(2,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(3,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(4,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(0,‘Invoice’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(1,‘Date’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(2,‘Total’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(3,‘Remaining’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(4,‘Status’);
Xojo.controls[‘XNSVsL7y’].deleteAllRows();
Xojo.controls[‘XNSVsL7y’].insertRow(0,[""]);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,1,“Aug 3, 2014”);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,2,“29.85”);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,3,“29.85”);
Xojo.controls[‘XNSVsL7y’].insertRow(1,[""]);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,1,“Jul 19, 2014”);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,2,“34.95”);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,3,“34.95”);
Xojo.controls[‘XNSVsL7y’].insertRow(2,[“000001”]);
Xojo.controls[‘XNSVsL7y’].setCellContents(2,1,“Jul 11, 2014”);
Xojo.controls[‘XNSVsL7y’].setCellContents(2,2,“0.00”);
Xojo.controls[‘XNSVsL7y’].setCellContents(2,3,“0.00”);
Xojo.controls[‘XNSVsL7y’].insertRow(3,[""]);
Xojo.controls[‘XNSVsL7y’].setCellContents(3,1,“Jan 23, 2014”);
Xojo.controls[‘XNSVsL7y’].setCellContents(3,2,“198.99”);
Xojo.controls[‘XNSVsL7y’].setCellContents(3,3,“198.99”);
Xojo.controls[‘XNSVsL7y’].setSelectedRows([0]);
Xojo.controls.Bik9QSwA.setItemToggled(“btnInvoices”,true);
Xojo.controls.Bik9QSwA.setItemToggled(“btnSubscriptions”,false);
Xojo.menus.create({ menuID: “VIJGUbit9K”, text: “”, enabled: true, children: [{ menuID: “SBdaoehoC2”, text: “Invoice Detail”, enabled: true, children: [] }] });
Xojo.controls.Bik9QSwA.items[“mnuActions”].menu = “VIJGUbit9K”;

Just noticed also that if I click the Subscriptions tab (after receiving this error) which sets the ColumnCount to 7, only 5 columns show up. When the container control is initialized, it is done so initially with the Invoices tab (ColumnCount = 5). If I then click the Credit Cards tab which defines only 4 columns, I receive the same error:

Could not execute returned javascript: Index or size is negative or greater than the allowed amount
Source: Xojo.controls[‘XNSVsL7y’].deleteAllRows();
Xojo.controls[‘XNSVsL7y’].setColumnCount(4);
Xojo.controls[‘XNSVsL7y’].setColumnWidths(’,20%,20%,20%’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(0,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(1,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(2,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(3,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(0,‘Name on Card’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(1,‘Last 4’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(2,‘Card Type’);
Xojo.controls[‘XNSVsL7y’].setColumnHeading(3,‘Expires’);
Xojo.controls[‘XNSVsL7y’].deleteAllRows();
Xojo.controls[‘XNSVsL7y’].setColumnWidths(’
,20%,20%,20%’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(0,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(1,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(2,‘COLLeft’);
Xojo.controls[‘XNSVsL7y’].setColumnStyle(3,‘COLRight’);
Xojo.controls[‘XNSVsL7y’].insertRow(0,[“Master Joe Card”]);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,1,“4444 (Default)”);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,2,“MasterCard”);
Xojo.controls[‘XNSVsL7y’].setCellContents(0,3,“5/2015”);
Xojo.controls[‘XNSVsL7y’].insertRow(1,[“Joe D User”]);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,1,“4242”);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,2,“Visa”);
Xojo.controls[‘XNSVsL7y’].setCellContents(1,3,“2/2016”);
Xojo.controls[‘XNSVsL7y’].setSelectedRows([0]);
Xojo.controls.Bik9QSwA.setItemToggled(“btnCards”,true);
Xojo.controls.Bik9QSwA.setItemToggled(“btnInvoices”,false);
Xojo.menus.create({ menuID: “CbfhK5HzCq”, text: “”, enabled: true, children: [{ menuID: “WNfFo6lmTr”, text: “Card Details”, enabled: true, children: [] },{ menuID: “MBKqJwlCl5”, text: “New Card”, enabled: true, children: [] },{ menuID: “MtH4JF7u9k”, text: “Delete Card”, enabled: true, children: [] },{ menuID: “GcGULxGDPO”, text: “Set as Default”, enabled: true, children: [] }] });
Xojo.controls.Bik9QSwA.items[“mnuActions”].menu = “CbfhK5HzCq”;

Here is the code from the method generating the error.

[code] lbItems.DeleteAllRows
lbItems.HeaderStyle = LBHeaderLightGray
Dim actionMenu As New WebMenuItem

Select Case List
Case 1 ’ Credit Cards
lbItems.ColumnCount = 4
lbItems.ColumnWidths = “*,20%,20%,20%”
lbItems.HasHeading = True
lbItems.ColumnStyle(0) = COLLeft
lbItems.ColumnStyle(1) = COLLeft
lbItems.ColumnStyle(2) = COLLeft
lbItems.ColumnStyle(3) = COLRight
lbItems.Heading(0) = “Name on Card”
lbItems.Heading(1) = “Last 4”
lbItems.Heading(2) = “Card Type”
lbItems.Heading(3) = “Expires”

// Create the Actions menu
actionMenu.Append(New WebMenuItem("Card Details"))
actionMenu.Append(New WebMenuItem("New Card"))
actionMenu.Append(New WebMenuItem("Delete Card"))
actionMenu.Append(New WebMenuItem("Set as Default"))

Case 2 ’ Invoices
lbItems.ColumnCount = 5
lbItems.ColumnWidths = “20%,20%,20%,20%,20%”
lbItems.HasHeading = True
lbItems.ColumnStyle(0) = COLRight
lbItems.ColumnStyle(1) = COLRight
lbItems.ColumnStyle(2) = COLRight
lbItems.ColumnStyle(3) = COLRight
lbItems.ColumnStyle(4) = COLLeft
lbItems.Heading(0) = “Invoice”
lbItems.Heading(1) = “Date”
lbItems.Heading(2) = “Total”
lbItems.Heading(3) = “Remaining”
lbItems.Heading(4) = “Status”

// Create the Actions menu
actionMenu.Append(New WebMenuItem("Invoice Detail"))

Case 3 ’ Subscriptions
lbItems.ColumnCount = 7
lbItems.ColumnWidths = “50,*,80,80,15%,15%,15%”
lbItems.HasHeading = True
lbItems.ColumnStyle(0) = COLLeft
lbItems.ColumnStyle(1) = COLLeft
lbItems.ColumnStyle(2) = COLRight
lbItems.ColumnStyle(3) = COLRight
lbItems.ColumnStyle(4) = COLRight
lbItems.ColumnStyle(5) = COLRight
lbItems.ColumnStyle(6) = COLRight
lbItems.Heading(0) = “Qty”
lbItems.Heading(1) = “Plan”
lbItems.Heading(2) = “Status”
lbItems.Heading(3) = “Amount”
lbItems.Heading(4) = “Start”
lbItems.Heading(5) = “Renews”
lbItems.Heading(6) = “Trial Expires”

// Create the Actions menu
actionMenu.Append(New WebMenuItem("Cancel Subscription"))

End Select

// Assign menu to the button
Dim actionButton As WebToolbarMenu
actionButton = WebToolbarMenu(tbBilling.ItemWithName(“mnuActions”))
actionButton.Menu = actionMenu
[/code]

One other thing Greg, If I don’t double-click any of the items in the WebListBox, I can freely go between the 3 tabs without error. However, I have noticed that the HeaderStyle does not stay consistent. I set the HeaderStyle each time I DeleteAllRows (2nd line in the sub in the previous post) but it has effect. My guess is these two issues are related. I can create a feedback case if desired.

Do that. Is like to see this in action.

Not sure what you are asking for Greg.

Create a Feedback report and attach a simple project that shows the error.

Greg . . . Any answers on this issue?

I still have not received a Feedback report with a project, so no.

What do you need?

I need a report filed in feedback with an example project attached so I can see the bug. As it is right now, I have no way to reproduce it, and without that I cannot fix it.

All I’ve got is my big project with bunches of files. Maybe this will help though:

This fixed the problem:
. . .
[code]cc.an.listbox2.deleteAllRows
cc.an.listbox2.columnCount = 30 — this line was added —
'cc.an.listbox2.columnCount = ubound(skills,2) + 1 — this line was commented out —
for k as integer = 0 to ubound(skills,2)
cc.an.listbox2.heading(k) = str(k+9)
next k
columnWidths = “44”
cc.an.listbox2.width = 44
for k as integer = 1 to ubound(skills,2)
columnWidths = columnWidths + “,44”
cc.an.listbox2.width = cc.an.listbox2.width + 44
next k
cc.an.listbox2.width = cc.an.listbox2.width + 30
cc.an.listbox2.columnWidths = columnWidths
for k as integer = 0 to ubound(skills,1)
cc.an.listbox2.addRow
for m as integer = 0 to ubound(skills,2)
cc.an.listbox2.cell(cc.an.listbox2.lastIndex,m) = skills(k,m)
next m
next k

next i[/code]

I tried
x = ubound(skills,2) + 1
cc.an.listbox2.columnCount = x
but it didn’t work.

Just before this bit I’ve got an almost identical part that fills listbox1.

Have you checked to see what the value of ubound(skills,2) actually is? Perhaps it’s not what you think?

Just out of curiosity… Have you tried your project in 2014r3? We fixed a few bugs in WebListBox which could account for this error.

Yep, I’ve checked ubound(skills,2). It’s what it should be. I’ve run it in 2014r3.

Lemme suggest that instead of checking the array bounds over and over that you assign that value to a variable and use that. I wonder if the data is changing behind your back.

I have the same problem, however it runs fine if i create 2 buttons, the first button executes the deleteAllRows only and the second button executes cc.an.listbox2.columnCount = ubound(skills,2) + 1 and the rest of the codes.

I have a similar problem that haunts me. The code behind is very extended and I can’t extract a part to make a sample project to replicate.
This is a schema of nested structure:

  • WebPage
    • ControlContainer
      • ControlContainer - In this ControlContainer there’s an array of textfields, buttons and a listbox; the number of array elements and column numbers is variable according to several factors. When I modify the listbox’s columns number in a specific condition, I get this error:

Could not execute returned javascript: Index or size is negative or greater than the allowed amount Source: Xojo.controls['N6IPIufD'].deleteAllRows(); Xojo.controls['N6IPIufD'].setColumnCount(1); Xojo.controls['N6IPIufD'].setColumnCount(2); ... ...... ........

You can see this error, connecting here and doing exactly this steps:
http://demo.dged.ch
Username: master
Password: 123
Wait till demo data are loaded.
Now reduce two times the font size with [CMD][-] (on Mac) or [CTRL][-] (on Windows)
Now go Up-Left and click on “Doc” icon and choose another document type.
When data are loaded, the error will appear.

Hope this can help all of us to solve the problem.

Hello @Pietro Beccegato !

I saw in your demo that the issue is gone…

Hoe did you solve it?