locked
HTML Client: reapply postrender functions after apply from editscreen RRS feed

  • Question

  • i have got several postrenderings like:

    myapp.gamedata_edit.filled_postRender = function (element, contentItem) {
        // Write code here.
        if (element.textContent == "true") {
            element.textContent = "complete";
            $(element).parent('div').parent('li').css("background", "#CCFFCC");
        }
    
        if (element.textContent == "false") {
            element.textContent = "incomplete";
            $(element).parent('div').parent('li').css("background", "#FFCCCC");
        }
    };

    when i edit the content of the entity 

    myapp.gamedata_edit.form1_Tap_execute = function (screen) {
        myapp.showForm1(screen.Form1.selectedItem, {
            afterClosed: function (addEditScreen, navigationAction) {
                if (navigationAction === msls.NavigateBackAction.commit) {
                    myapp.activeDataWorkspace.GameData.saveChanges();
                    screen.Form1.selectedItem.details.refresh();
                    //i guess here i need to reapply the postrendering...
                }
            }
        })
    };

    i removed the postrendering to check if the data is correctly saved (true to false and vice versa) and yes it works.

    thank you in advance, 

    best regards



    Monday, March 24, 2014 4:34 PM

Answers

  • You can use data binding to update the background whenever the value of the filled contentItem changes.  You should check in your specific instance though what type "contentItem.value" is. If it's of boolean type, you can use the code below. If not, you may have to specify a longer path to get to the property you want: "value.somePropertyName"

    myapp.gamedata_edit.filled_postRender = function (element, contentItem) {
        contentItem.dataBind("value", function (newValue) {
            if (newValue == true) {
                // Do stuff here with element
            }
    
            if (newValue == false) {
                // Do stuff here with element
            }
        });
    }

    • Proposed as answer by ADefwebserver Monday, March 24, 2014 5:52 PM
    • Marked as answer by GRothensteiner Tuesday, March 25, 2014 8:29 AM
    Monday, March 24, 2014 5:41 PM

All replies

  • You can use data binding to update the background whenever the value of the filled contentItem changes.  You should check in your specific instance though what type "contentItem.value" is. If it's of boolean type, you can use the code below. If not, you may have to specify a longer path to get to the property you want: "value.somePropertyName"

    myapp.gamedata_edit.filled_postRender = function (element, contentItem) {
        contentItem.dataBind("value", function (newValue) {
            if (newValue == true) {
                // Do stuff here with element
            }
    
            if (newValue == false) {
                // Do stuff here with element
            }
        });
    }

    • Proposed as answer by ADefwebserver Monday, March 24, 2014 5:52 PM
    • Marked as answer by GRothensteiner Tuesday, March 25, 2014 8:29 AM
    Monday, March 24, 2014 5:41 PM
  • Cool, it works :-)

    Thank you very much!

    Tuesday, March 25, 2014 8:30 AM