Infopath Coding Conditional Formatting and Item Page-Thru - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Infopath Coding Conditional Formatting and Item Page-Thru

Last post 08-22-2011 07:46 AM by alexteno. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 08-16-2011 05:21 AM

    Infopath Coding Conditional Formatting and Item Page-Thru


    I'm looking for some help in modifying a form for two purposes. We would like to use conditional formatting to modify the coloring of a table or of the background, or even to modify the color scheme entirely if a Checkbox has been marked. Unfortunately, it doesn't look like there are conditional formatting options to modify regular table options, or to change the colour scheme (that I can find). If anybody knows how to make this happen either through .Net Programmability or some clever conditional formattery, I'd appreciate it.

    My second issue, We have a repeating table that slows down with many lines of code, I've been searching for threads about this issue, and I know a solution, I just don't know how to make it happen. Ideally, we'd like to have the items of the repeating table be paged thru (1 - 10, 11 - 20, 21-30, etc...) in order to reduce the load when the form is opening.

    Help or links to solutions would be amazing, thanks guys.

    Alex
  • 08-16-2011 10:11 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    I believe you can use Section controls to fill each of your table cells and put conditional formatting on those.  Have you tried that?

    Perhaps it's because I don't know what your code is doing, but I don't see how iterating through a repeating section in small bunches would improve the speed.  Could you elaborate on that?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-16-2011 10:20 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru


    To elaborate on the Page Thru idea, from what I've seen when loading the form (not a webform) it seems to load all of the lines into memory. On slower computers - i.e. the one's at my organization - it takes anywhere from 15 seconds to 5 minutes to load the form based on how many lines exist in the repeating table. Our longest form to load is roughly 5 minutes with about 237 lines in the repeating table.

    I haven't heard of sections before not, but since I now know what to look for, I'll investigate and see if it would be useful to solve this problem.
  • 08-17-2011 07:30 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    I don't think sections are going to work. The repeating table is just that, a repeating table. There is no separation between line items. I think what I'm looking for is closer to a filter.
  • 08-17-2011 08:04 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    Sorry, I didn't realize that you were using a repeating table. Repeating tables' conditional formatting is perfectly capable of changing the table's background.  You'd need to modify the conditional formatting on the controls inside it to change their color.  You can't simply switch everything to another color scheme, but you can set up conditional coloring that way.

     Would you mind sharing the code in question with us?  I'm curious which part of it you believe to be loading everything into memory.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-17-2011 08:12 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru


    Sorry, I may not have made it clear in my first post that I have two separate issues. I'm not trying to format the repeating table, it's that large repeating tables seem to load very slowly (with many rows).

    The other issue (the programming one) I have a checkbox on the form, when it is checked, ideally I'd like to have the background colour of the form change.

    I probably should've made two topics, that's my mistake.

    To reiterate
    Problem 1: Repeating table with many lines load very slowly.
    Problem 2: Would like to change the background colour of the entire form with either conditional formatting or .NET when a checkbox has been marked.
  • 08-17-2011 08:43 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    Ah, I see now.  Paging is fairly easy.  Add a field called pageNo in your form and add conditional formatting to hide its rows on the condition

    pageNo Is not equal to floor(count(preceding-sibling::my:repeatingGroupName)) + 1

    You cannot use code to control the formatting of your form.  It's not possible to change the background color of the entire canvas, but you can place the main part of your form in a large section control, and use conditional formatting to control its color.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-17-2011 09:06 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    Thanks for that info. I'll be attempting that later today. I'll update whether or not that solves the problem =D
  • 08-17-2011 01:38 PM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    I've had time to do the Section and conditional formatting. Worked brilliantly. I'll check with Pageing tomorrow (ran out of time today)
  • 08-19-2011 05:21 AM In reply to

    • TedCa
    • Not Ranked
    • Joined on 08-13-2011
    • Posts 4

    Re: Infopath Coding Conditional Formatting and Item Page-Thru

    Is the slow performance caused by using rich text boxes ? If so could you switch to text boxes?

  • 08-22-2011 07:46 AM In reply to

    Re: Infopath Coding Conditional Formatting and Item Page-Thru


    Hey gentleman. Greatly appreciate all your help. Works wonderfully

    We were able to use a section and a check box (with Conditional Formatting) as a strong visual indicator that something on the form had been marked

    More importantly though...
    The ridiculous load times have been essentially eliminated by using this paging idea. I set up our form to page through several at a time and by default load with 10. It is loading significantly faster with only 10 lines since (responding to TedCa), yes, we are using RTF boxes and not plaintext. Sadly though these RTF boxes are part of our requirements.

    In regards to code, I've added a little bit of stuff past the initial single line as follows

    .NET Coded events

    public void pageAmount_Changed(object sender, XmlEventArgs e)
    {
       CreateNavigator().SelectSingleNode("/my:myFields/@my:pageNo", NamespaceManager).SetValue("0");
    }

    public void PageNext_Clicked(object sender, ClickedEventArgs e)
    {
       int i;
       i = (int)CreateNavigator().SelectSingleNode("/my:myFields/@my:pageNo", NamespaceManager).ValueAsInt;
       i--;
       CreateNavigator().SelectSingleNode("/my:myFields/@my:pageNo", NamespaceManager).SetValue(i.ToString());
    }

    public void PagePrev_Clicked(object sender, ClickedEventArgs e)
    {
       int i;
       i = (int)CreateNavigator().SelectSingleNode("/my:myFields/@my:pageNo", NamespaceManager).ValueAsInt;
       i++;
       CreateNavigator().SelectSingleNode("/my:myFields/@my:pageNo", NamespaceManager).SetValue(i.ToString());
    }

    Fields, Objects, Attributes, Etc...
    pageNo - WholeNumber - Default Value: Expression: 0, Updating
    pageMax - Text - Default Value: Expression: max(RepeatingTable\LineNo), Updating
    pageAmount - Text
    pageUpper - Text - Default Value: Expression: @pageMax - (@pageNo * pageAmount)
    pageLower - Text - Default Value: Expression: concat(substring("0", 1, (@pageMax
    Note the above was a boolean statement in order to prevent my lower field from being a negative value (stops at zero), I imagine some of you guys have already seen this kind of expression

    Form Load Rule:
    Always Runs - concat(substring("99999", 1, ((get-Role() = "Role1") or (get-Role() = "Role2") or (get-Role() = "Role3")) * string-length("99999")), substring("10", 1, (not(((get-Role() = "Role1") or (get-Role() = "Role2") or (get-Role() = "Role3")))) * string-length("10")))

    Conditional Formatting:

    Repeating Table:
    if RepeatingTable\LineNo > pageUpper or
    if RepeatingTable\LineNo
    Hide this Control


    Again, thanks for all your help!
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.