How to prepopulate rows into DataTable in Plumsail

@Margo so it goes like this:
user completes the New Form and gets redirected to Edit after saveing. There is a Data table on Edit form and I need the first raw to be prepopulated with "1" in the first column and a field value from the form in the second.

I tried adding your code after mine like this:

fd.rendered(function(){
    var dt_rows = [];
    var row1 = {PYear: "1"};
    dt_rows.push(row1);
    fd.control('FA').value = dt_rows;
});

fd.rendered(function(){
    var row = fd.control('FA').widget.dataSource.data()[0];
    row.set("VolProj", fd.field('CEW_x002d_Base').value);
});

and tried to insert it into mine as well:

fd.rendered(function(){
    var dt_rows = [];
    var row1 = {PYear: "1"};
    dt_rows.push(row1);
    fd.control('FA').value = dt_rows;
    var row = fd.control('FA').widget.dataSource.data()[0];
    row.set("VolProj", fd.field('CEW_x002d_Base').value);
});

but I still can't get the second column to be populated with field value :disappointed:

@katy,

What is the type of the 'CEW_x002d_Base' field?

@Margo this is just a number, but ideally I need to point to calculated field (as number as well)

@Margo Hi Margarita, Is there any chance you looked into this?

Dear @katy,
You can try it like so:

fd.spRendered(function(){
    var dt_rows = [];
    var row1 = {PYear: "1", VolProj: fd.field('CEW_x002d_Base').value};
    dt_rows.push(row1);
    fd.control('FA').value = dt_rows;
});

Thank you @Nikita_Kurguzov ! That worked perfectly! And with a calculated field as well!
Thank you very much!

1 Like