O4W add rows and data to existing table on WYSIYG form (O4W)
At 19 APR 2023 12:41:12AM Barry Stevens wrote:
I have a table(EditTable) on a form and I want to add rows and data to the table.
I have this test code, but how do I get the tablename as it does not appear to be the element name, or, am I still missing something.
tableName='element24' Num.values = dcount(myData, @fm) For each.value = 1 to num.values this.job = myData<each.value> *O4WTextbox(this.job, "", "", "JOB_DETAILS", "JOB_":EACH.VALUE) O4WTableAddRow(tableName, each.value, "JOB_":EACH.VALUE) O4WSetCell(each.value, 1,tablename) O4WUpdate(tablename, this.job, O4WResponseOptions("1")) o4wbutton("Select","BTN_SEL_":each.value) o4wqualifyevent("BTN_SEL_":each.value,"CLICK") Next each.value
At 19 APR 2023 08:57AM bshumsky wrote:
Hi, Barry.
It looks like you want to populate the table entirely from code - is that correct?
If that's the case, then I'd suggest you're better off creating the table from scratch. Although the O4WCommuterUtility will give you the name of the table associated with the element, and O4WTableAddRow will add in a blank row, I don't think you can use O4WUpdate in this fashion. Instead, you can use O4WCommuterUtility to get the name of the table and the name of the "section" that surrounds the element, and then use O4WTableStart/O4WTableEnd to make the entire table as you wish.
I _think_ something like this will work:
sectValue = O4WCommuterUtility("", O4WUTILITY_FORMELEMENT_CONTROL_CELL$, "element24")
If sectValue <> "" Then
tblValue = O4WCommuterUtility("", O4WUTILITY_TABLENAME$, "element24")If tblValue <> "" ThenO4WSectionStart(sectValue, O4WResponseStyle())O4WTableStart(tblValue)
build your table hereO4WTableEnd(tblValue)O4WSectionEnd(sectValue)endend
There may be some extra 'tweaks' to the above, but that's the general idea I think…
- Bryan Shumsky
At 19 APR 2023 07:18PM Barry Stevens wrote:
Hi, Barry.
It looks like you want to populate the table entirely from code - is that correct?
If that's the case, then I'd suggest you're better off creating the table from scratch. Although the O4WCommuterUtility will give you the name of the table associated with the element, and O4WTableAddRow will add in a blank row, I don't think you can use O4WUpdate in this fashion. Instead, you can use O4WCommuterUtility to get the name of the table and the name of the "section" that surrounds the element, and then use O4WTableStart/O4WTableEnd to make the entire table as you wish.
I _think_ something like this will work:
sectValue = O4WCommuterUtility("", O4WUTILITY_FORMELEMENT_CONTROL_CELL$, "element24")
If sectValue <> "" Then
tblValue = O4WCommuterUtility("", O4WUTILITY_TABLENAME$, "element24")If tblValue <> "" ThenO4WSectionStart(sectValue, O4WResponseStyle())O4WTableStart(tblValue)
build your table hereO4WTableEnd(tblValue)O4WSectionEnd(sectValue)endend
There may be some extra 'tweaks' to the above, but that's the general idea I think…
- Bryan Shumsky
..you're better off creating the table from scratch.That was my thinkinking also by using the table as a placemarker.
Looks like I need to study up on these moving forward for the complete app development:
O4WUTILITY_FORMELEMENT_CONTROL_CELL$, O4WUTILITY_TABLENAME$
as all my data fills are not directly from oi tables, but are assembled.
Thanks for the continuing heads-up