First add a method on the form to populate records in the temporary table:
public LabelsTable populateRecords() { SysDictTable dictTable = new SysDictTable(tableNum(PurchLine)); SysDictField dictField; TreeNode treeNode; LabelsTable labelsTableLocal; // Temporary table (InMemory) FieldId fieldId = dictTable.fieldNext(0); while (fieldId) { dictField = dictTable.fieldObject(fieldId); if (dictField.isSql() && !dictField.isSystem() && dictField.name() != "Modified") { treeNode = dictField.treeNode(); labelsTableLocal.Field = dictField.name(); labelsTableLocal.Label = treeNode.AOTgetProperty("Label"); labelsTableLocal.insert(); } fieldId = dictTable.fieldNext(fieldId); } return labelsTableLocal; }
Then override form’s init() method and add the following code to display the temporary table data on the form:
public void init() { super(); LabelsTable.setTmpData(element.populateRecords()); }
Small point, but if the table is a the type TempDB, then the line LabelsTable.setTmpData(element.populateRecords()) will not work, you need to change it to LabelsTable.linkPhysicalTableInstance(element.populateRecords()) and then all is good
Thanks for the info 🙂
really helpful thanks!
my code it’s working fine on regulate table only
but how can i make it work with temp table it’s doesn’t shown on grid after add
void clicked()
{
int i;
str testproductname;
real denominator;
denominator=BasePurchasePrice.realValue()/((NumberPartsCMB.selection()+1)/2*NumberPartsCMB.selection());
ttsBegin;
for(i=1;i<=NumberPartsCMB.selection();i+=1)
{
testproductname=Identification_Name.valueStr();
temp.NameProductParts=int2str(i)+'-'+testproductname;
temp.PurchProductParts=i*denominator;
temp.SalesProductParts=i*(SalesBasePrice_Price.realValue()/(((NumberPartsCMB.selection()+1)/2)*NumberPartsCMB.selection()));
temp.QTYProductParts=QTYPartsTXT.value();
temp.insert();
}
ttsCommit;
super();
TempProductPartsDS_DS.refresh();
TempProductPartsDS_DS.research();
}