Working with the edit table, I've discovered a bug in it when using events on fields in a repeat row. Here is the situation:
1. I have a select field with an on change, set field event that updates another field with the selected value.
2. It works correctly for the "blank" row.
3. It works correctly for rows loaded from the server.
4. It does not work for rows newly inserted ("insert" link), then edited (edit button). The value comes from the "blank" row because the repeat row variable passed to the function in the html is the blank row, not the current repeat row.
This issue affects anything using that repeat row value.
Here is the html that shows. You can see the event is passed an incorrect repeat row value.
1. I have a select field with an on change, set field event that updates another field with the selected value.
2. It works correctly for the "blank" row.
3. It works correctly for rows loaded from the server.
4. It does not work for rows newly inserted ("insert" link), then edited (edit button). The value comes from the "blank" row because the repeat row variable passed to the function in the html is the blank row, not the current repeat row.
This issue affects anything using that repeat row value.
Here is the html that shows. You can see the event is passed an incorrect repeat row value.
<select???+?class="select"???+?id="record_repeat2CENTER_DEPT"???+?name="record_repeat2CENTER_DEPT"???+?onchange="return???+?CENTER_DEPTonchange(event,???+?'record_repeatBlankEntry');???+?...
RE: Edit Table Events Error - Wrong repeat row id
Unfortunately this is a known issue with the editable table in 3.1.2 that has been fixed for future releases.
You can work round the problem by adding a custom script action to your onchange event before the existing actions, containing the following type of code.
you will need to adjust the substr command to allow for the length of the field name.
var fieldId = objEventSource.component.id; //remove the field name from the full ID to get the repeat ID value //this assumes a field name of CENTER_DEPT with length 11 repeatId = fieldId.substr(0, fieldId.length - 11); objEventSource.repeatId = repeatId;
I hope this helps.
Regards,
Gerard
RE: Edit Table Events Error - Wrong repeat row id
Thanks so much! That did the trick.
I was trying to use 'this', but wasn't successful. I see that the component.id is getting it's value from the field triggering the event. I didn't think of that. I'm still a novice on the javascript stuff. I did do a little change to your code. Here's what I'm doing:
var fieldId = objEventSource.component.id; repeatId = fieldId.replace('CENTER_DEPT',''); objEventSource.repeatId = repeatId; objEventSource.field = document.getElementById(fieldId)
Gary