locked
LS2013 HTML Client: On a browse screen containing a list, how can I access a row's other fields from a postrender method? RRS feed

  • Question

  • Hello,

    I have a browse screen that displays blood pressure values.  For each row on the browse screen, I need to display a text string that indicates whether the blood pressure is normal or not.  So, I created a local string property, "RiskCategory", on the screen, and created a postrender method for it.  What I cannot figure out, is how to access the row's Systolic and Diastolic values in the postrender event for RiskCategory for the current row being processed.  Here is the code for the postrender method:

    myapp.BrowseBloodPressuresSorted.RiskCategory_postRender = function (element, contentItem) {
        contentItem.value = assessBloodPressureRisk(contentItem.screen.MetricsSorted.Systolic,
                                                    contentItem.screen.MetricsSorted.Diastolic);
    };

    Basically, the question is how to access a row's other fields from any postrender method for the row.  Here is an image of the browse screen definition:

    I'd really appreciate your help with this question.

    Thanks,

    Mike


    Sunday, January 19, 2014 6:25 PM

Answers

  • Any problem is with the code that I gave you. Unfortunately I do not have any code that matches your situation exactly or I would just point you to it. So I guessed and I feel I guessed wrong.

    What I would try is this:

    1) Under the List control, change the Rows Layout to a Custom Control

    2) The Custom control is now bound to the entire entity for the row.

    3) Click the Render button on the custom control and implement the complete output. Output on innerHTML lik e this:

    element.innerHTML = "<h2>Buy a Copy</h2> </br>";


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Monday, January 20, 2014 4:08 PM

All replies

  • From the image it looks like MetricsSorted is the collection that the list above is bound to.

    You add .data to contentItem

    So it should be:

    contentItem.value =

    assessBloodPressureRisk(contentItem.data.Systolic, contentItem.data.Diastolic);



    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com




    Sunday, January 19, 2014 10:20 PM
  • Hi Michael,

    Thank you very much for the correction!  I've implemented the change, but, unfortunately, I am getting some strange behavior.  For each row, the Systolic, Diastolic, and BPM have correct values.  However, when I emit the Risk from the postRender method, I am getting incorrect risk category results.  So, I added the display of the values being used to determine the Risk in the postRender method, and they do not match the values for the row's Systolic and Diastolic fields.  Strange...  I'd appreciate any ideas about what I am doing wrong.   Here is a dump from the browse screen...

    myapp.BrowseBloodPressuresSorted.RiskCategory_postRender = function (element, contentItem) {
        contentItem.value = contentItem.data.Systolic + ", " +
                            contentItem.data.Diastolic + ", " +
                            getBloodPressureRiskDescription(contentItem.data.Systolic,
                                                            contentItem.data.Diastolic);
    };

    Thank you for your help and time!

    Mike



    Monday, January 20, 2014 3:50 PM
  • Any problem is with the code that I gave you. Unfortunately I do not have any code that matches your situation exactly or I would just point you to it. So I guessed and I feel I guessed wrong.

    What I would try is this:

    1) Under the List control, change the Rows Layout to a Custom Control

    2) The Custom control is now bound to the entire entity for the row.

    3) Click the Render button on the custom control and implement the complete output. Output on innerHTML lik e this:

    element.innerHTML = "<h2>Buy a Copy</h2> </br>";


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Monday, January 20, 2014 4:08 PM
  • Ahhh... That is a great idea, Michael!  This ensures that all of the fields that I want to use are consistent...  I will give it a whirl and report back.  Thank you for your suggestion! :)
    Monday, January 20, 2014 4:56 PM
  • Your idea worked like a charm!  Thanks, Michael!
    Monday, January 20, 2014 5:30 PM