Page 1 of 2

Add rows to subform

Posted: Sun Jul 08, 2018 6:39 am
by marc
Hey,

I created a form that contains a subform grid. Upon loading the edit screen, I run a script to add some additional rows to the subform.

Like this:

Code: Select all

nuAddRow('sub_grid' );
nuAddRow('sub_grid' );
nuAddRow('sub_grid' );
nuAddRow('sub_grid' );
nuAddRow('sub_grid' );
But just one row is added, not 5!

Test done with a nuBuilder Form: Same result!
addrow.JPG

Code: Select all

nuAddRow('accform' );
nuAddRow('accform' );
nuAddRow('accform' );
nuAddRow('accform' );
How do I prepopulate more than one row?

Re: Add rows to subform

Posted: Mon Jul 09, 2018 8:37 am
by toms
marc,

It works for me - but only if the first control is a not a lookup object. It seems to be a glitch.

Workaround: add a dummy input field as first element in the grid with width = 0 and disabled = false.

Re: Add rows to subform

Posted: Wed Jul 11, 2018 3:25 am
by admin
marc,

It works for me as well.

Steven

Re: Add rows to subform

Posted: Wed Jul 11, 2018 5:47 am
by marc
admin wrote:marc,

It works for me as well.

Steven
@Steven:
and you tried it on a subform where the first element is a lookup object?
(see my example above, access level screen, forms grid)

@toms: WIll give it a go unless there's a patch.

Re: Add rows to subform

Posted: Wed Jul 11, 2018 7:37 am
by toms
Timo, yes the issue only occurs when the the first object in a grid row is a lookup object.
2018-07-11_073153.png
If you add several rows in one go, only 1 row will be added:

Code: Select all

nuAddRow('accform' );
nuAddRow('accform' );
nuAddRow('accform' );
nuAddRow('accform' );
nuAddRow('accform' );
Eg. if you add a timeout before adding a new row, all rows will be added.

Code: Select all

var d  = 50;
for (i = 0; i < 20; i++) { 
  setTimeout(function() {
  nuAddRow('accform' );
}, d);
d += 50;
}

Re: Add rows to subform

Posted: Fri Jul 20, 2018 3:50 pm
by marc
@Steven Have you been able to reproduce this bug?
the issue only occurs when the the first object in a grid row is a lookup object.

Re: Add rows to subform

Posted: Sun Jul 22, 2018 11:45 pm
by admin
marc,

No, I can't.

It works for me on Access Levels > Form Tab (which starts with a Lookup).

Steven

Re: Add rows to subform

Posted: Tue Jul 24, 2018 7:25 am
by marc
Hi,

I got the latest from Gihub. Still one row is added, although I add several. I also recorded a Video so you could see it visually.

https://streamable.com/jdoph

I also tried it on your demo site https://demo.nubuilder.net/ with the same result.

Re: Add rows to subform

Posted: Tue Jul 24, 2018 10:23 pm
by admin
marc,

It seems the process of loading a lookup in a new row (which may need data from the server) means you may need to pause between running nuAddRow().

I would just use toms workaround.

Steven

Re: Add rows to subform

Posted: Sat Jul 28, 2018 9:29 am
by marc
admin wrote: It seems the process of loading a lookup in a new row (which may need data from the server) means you may need to pause between running nuAddRow().
Well, the adding works well if the lookup is not the first element in the row. That's why I think there's another reason.