Checkbox in Repeating Table Only Fires OnChange Event From Last ro

L

liz-kma

Hello,

I have a repeating table bound to a local data source, Interviewer. The
interviewer name is stored in interviewer and selected, a boolean field, is
stored as an attribute of interviewer.

Here's the local data structure:

Interviewers, Group
Interviewer, Repeating Element
Selected, Attribute
Email, Attribute
Phone, Attribute

The problem I'm having is that clicking on the checkbox only fires the
validation event when you click in the last row. And that event seems to be
correct. But when you click on the checkbox in any other row, it does not
fire an event.

Has anyone seen this? Is there something I'm missing?

Thanks,
Liz
 
S

Scott L. Heim [MSFT]

Hi Liz,

I wonder if the behavior you are seeing is caused by not having the
"correct row?" That's just speculation on my part but I would like to share
sample steps with you where the OnValidate event for my check box fires
each time. Try these steps and let me know the results:

- Create a new, blank InfoPath solution
- Add a Repeating Table with 2 columns (field1 and field2)
- Change field2 to a Check Box control
- Right-click on field2 and choose Properties
- Click the Data Validation button
- From the Events box choose OnValidate and click Edit
- You should see the following:

function msoxd_my_field2::OnValidate(eventObj)
{
// Write your code here
}

- Add this code between the braces:

var objField1 = eventObj.Site.parentNode.selectSingleNode("my:field1");

if(objField1.text != "")
{
if(eventObj.Operation == "Insert")
{
XDocument.UI.Alert(objField1.text);
}
}

- Save the script, Preview the form, add data to field1 and click the check
box. In my results, the check box OnValidate event fires each time.

Let me know if this works for you...or if I completely missed the boat on
the behavior you are seeing! :)

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

bratt

I had unexpected checkbox event firing when I had a repeating table
bound directly to a secondary datasource - IP assumed the data to be
readonly. I ended up copying the secondary datasource to a group on the
main datasource onload() and rebound the repeating table to the main
group. Events then worked as expected. I also removeChild nodes from
the holding group before submitting to keep the xml cleaner.
 
L

liz-kma

Hello Scott and Bratt,

Yes, Bratt, I'm experiencing a similar problem. The event only fires from
the checkbox upon insertion (and likely deletion) in a repeating table
although, if it's the last row, it fires correctly all the time -- anytime
there is a change. I assumed it might be a secondary data connection problem
and switched to storing the data on the local side.

But I still have the same problem. Now I'm thinking it has to do with
values that are stored as attributes as I did have everything working with a
secondary data source previously when nothing was stored as an attribute.

I'm going to switch back to elements, avoid using attributes, and see if I
can get it working again...

Thanks,
Liz
 
L

liz-kma

Hi Bratt,

Now I've moved everything into local data using a repeating group with child
elements. I'm still having the same problem. The one thing I do notice is
that the XML that is automatically generated by appendChild has no line-wrap,
although the elements themselves are correct.

Are you cleaning up the xml in string format before you add it to the local
data source? (Just asking you mentioned dropping child nodes...)

Thanks!

-- Liz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top