locked
LS HTML - View and edit screen RRS feed

  • Question

  • Hi,

    For many of my HTML view screens I had to create the exact same screen for edit. Isn't there a way to use the same screen to view and edit?

    Tks.

    François



    • Edited by francois.m Thursday, June 13, 2013 7:44 AM
    Thursday, June 13, 2013 7:43 AM

Answers

  • Hi,

    This code or something similar may work, I have not tested it on complex screens!

        var root = screen.details._rootContentItem;
        $.each(root.children, setReadonly);
    
        function setReadonly(n, item) {
            if (item.children[0]) {
                $.each(item.children, setReadonly);
            } else {
                screen.findContentItem(item.name).isReadOnly = true;
            }
        }

    Cheers

    Dave


    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.


    Thursday, June 13, 2013 10:55 AM

All replies

  • Do you mean flip the input controls between read-only/editable in an edit screen?

    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.

    Thursday, June 13, 2013 8:15 AM
  • No. I would say the other way around. Make a view screen editable. Indeed, from the browse screen it is natural to go to a view screen on tap. And there, it is natural to click on an edit button. This is where I open an edit screen but I would prefer to make my view screen editable. Maybe I can do so by changing all my labels to textboxes but I'm checking if there isn't a "normal" method that I missed.
    Thursday, June 13, 2013 9:23 AM
  • You can do that but you will have to handle the buttons yourself, if you start from an edit screen then save is already there.

    The controls will need to be input controls to toggle between editable/read-only as you say.

    I don't know of any other way of doing this other than:

    screen.findContentItem("mycontrol").isReadOnly = true; //false;


    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.


    • Edited by Xpert360 Thursday, June 13, 2013 9:40 AM
    Thursday, June 13, 2013 9:40 AM
  • Tks Xpert360, this is what I was afraid of :-(
    Thursday, June 13, 2013 9:46 AM
  • Anyway of looping accross all controls in javascript rather than having one line to enter manually for each control (due to the name of the control), which is almost as bad for maintenance as having two screens as I have now?
    Thursday, June 13, 2013 9:48 AM
  • Hi,

    This code or something similar may work, I have not tested it on complex screens!

        var root = screen.details._rootContentItem;
        $.each(root.children, setReadonly);
    
        function setReadonly(n, item) {
            if (item.children[0]) {
                $.each(item.children, setReadonly);
            } else {
                screen.findContentItem(item.name).isReadOnly = true;
            }
        }

    Cheers

    Dave


    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.


    Thursday, June 13, 2013 10:55 AM