Current Row in repeating table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Current Row in repeating table

Last post 04-24-2009 11:19 AM by hortonhouse. 31 replies.
Page 3 of 3 (32 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 03-22-2009 10:37 PM In reply to

    Re: Current Row in repeating table

    Those instructions make sense to me.  Are you sure you modified the manifest the way they described?  Perhaps you could attach your manifest.xsf file to this thread so we can have a look?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-24-2009 11:19 AM In reply to

    Re: Current Row in repeating table

     I have a mechansim where I select only the current item with a check box and unselect the previous, I then use a link button to allow selection of the correct row. The elements needed are firstly for InfoPath form Memebr variables (all in C#):

            /// <summary>
            /// Is a table postback. Changiong a check box value causes immediate postback which must be filtered out.
            /// </summary>
            private bool TablePostBack
            {
                get
                {
                    return Convert.ToBoolean(FormState["TablePostBack"]);
                }
                set
                {
                    FormState["TablePostBack"] = value;
                }
            }

            /// <summary>
            /// Prev table index.
            /// </summary>
            private int PrevTableIndex
            {
                get
                {
                    return Convert.ToInt32(FormState["PrevTableIndex"]);
                }
                set
                {
                    FormState["PrevTableIndex"] = value;
                }
            }

     I then have a table which is bound in C# code behind in a method to data values as follows... Be sure that you specify the fields in the xmlWriter in the order in which they are in your data source and also that everything is in its own group otherwise you will get the shema validation errors problem...

                             // Iterative fields... Contact attachments... *************************************************************************************************************
                            XPathNavigator xmlItemAttachments = MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpAttachments", NamespaceManager);
                            // Remove first element since this is a given.
                            xmlItemAttachments.SelectSingleNode("/my:ReferralContact/my:grpAttachments/my:Attachments[1]", NamespaceManager).DeleteSelf();
                            foreach (ContactWrap.FormServiceProxy.AHLAttachment objAttachment in objData.ContactAttachments)
                            {
                                using (XmlWriter xmlWriter = xmlItemAttachments.AppendChild())
                                {
                                    xmlWriter.WriteStartElement("Attachments", xmlItemAttachments.NamespaceURI);
                                    xmlWriter.WriteElementString("AttachmentType", xmlItemAttachments.NamespaceURI, Convert.ToString(objAttachment.TypeResolved));
                                    xmlWriter.WriteElementString("AttachmentName", xmlItemAttachments.NamespaceURI, objAttachment.Name);
                                    xmlWriter.WriteElementString("AttachmentDescription", xmlItemAttachments.NamespaceURI, objAttachment.Description);
                                    xmlWriter.WriteElementString("AttachmentVersion", xmlItemAttachments.NamespaceURI, Convert.ToString(objAttachment.Version));
                                    xmlWriter.WriteElementString("AttachmentDate", xmlItemAttachments.NamespaceURI, XmlConvert.ToString(objAttachment.Date, "yyyy/MM/dd HH:mm:ss"));
                                    xmlWriter.WriteElementString("chkSel", xmlItemAttachments.NamespaceURI, (objAttachment.Selected == true ? "1" : "0"));
                                    xmlWriter.WriteEndElement();
                                    xmlWriter.Close();
                                }
                            }
                            // *******************************************************************************************************************************************************


    Now handle the event for the table repeating checkbox click and update the URL and URLText values for which a Link button is bound to in data...

    /// <summary>
            /// Check box click event.
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            public void chkSel_Changed(object sender, XmlEventArgs e)
            {
                // Only with valid entry change, not just load event.
                if (e.OldValue != string.Empty)
                {
                    int intSelectedIndex = -1;
                    XPathNodeIterator xmlNodesCheck = MainDataSource.CreateNavigator().Select("/my:ReferralContact/my:grpAttachments/my:Attachments", NamespaceManager);
                    int intCount = -1;
                    foreach (XPathNavigator xmlNodeNav in xmlNodesCheck)
                    {
                        ++intCount;
                        if (xmlNodeNav.SelectSingleNode("my:chkSel", NamespaceManager).Value == "1")
                        {
                            intSelectedIndex = intCount;
                            // this.LastTableIndex = intCount;
                            if (this.PrevTableIndex != intCount)
                            {
                                // Reset old value.
                                int intInnnerCount = -1;
                                foreach (XPathNavigator xmlNodeNavInner in xmlNodesCheck)
                                {
                                    if (++intInnnerCount == this.PrevTableIndex)
                                    {
                                        // Evaluluate all...
                                        xmlNodeNavInner.SelectSingleNode("my:chkSel", NamespaceManager).SetValue("0");
                                        // Stop immediate reprocess for old item undo.
                                        this.TablePostBack = true;
                                        break;
                                    }
                                }
                                this.PrevTableIndex = intCount;
                                break;
                            }
                        }
                    }
                    // Reconcile to data. Set HTML link values ready for use...
                    if (this.ListOfAttachmentsCached != null && this.ListOfAttachmentsCached.Length > 0 && intSelectedIndex >= 0)
                    {
                        // Get the link from the contact attacment library link data element which has already been set.
                        if (MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:ContactAttachmentLibraryLink", NamespaceManager).Value == string.Empty)
                        {
                            // Point to lib.
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURLText", NamespaceManager).SetValue("Error: Could not obtain attachmement library URL...");
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURL", NamespaceManager).SetValue(MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:ContactAttachmentLibraryLink", NamespaceManager).Value);
                        }
                        else if (this.ListOfAttachmentsCached[intSelectedIndex].Name == string.Empty)
                        {
                            // Point to empty. Can't do anything.
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURLText", NamespaceManager).SetValue("Error: Could not obtain attachment item details....");
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURL", NamespaceManager).SetValue(string.Empty);
                        }
                        else
                        {
                            string strLinkURL = MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:ContactAttachmentLibraryLink", NamespaceManager) + "/" + this.ListOfAttachmentsCached[intSelectedIndex].Name;
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURLText", NamespaceManager).SetValue("Open");
                            MainDataSource.CreateNavigator().SelectSingleNode("/my:ReferralContact/my:grpControl/my:AttachmentSelectedItemLinkURL", NamespaceManager).SetValue(strLinkURL);
                        }
                    }
                }
            }

     

    Andrew Maisey
Page 3 of 3 (32 items) < Previous 1 2 3
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.