This topic is locked
[SOLVED]

 Trying to hide fields on List page

8/12/2020 2:58:21 PM
ASPRunner.NET General questions
W
WebReports author

Using AspRunner.Net v9.8
This is similar to the Hide Fields on the Edit/Add pages, which I have working great. Now, I am trying to hide fields on the List page in a similar manner.
I have tried to use 'pageObject.hideField("")' in both the 'List page: Before record processed' and 'List page: After record processed'. I also tried to add a 'setProxy' in the 'Before Display' then using the javascript code to hide it, but it appears that the 'Before Display' is for the entire page an not per record.

T
Tim 8/12/2020

This is easy in 10.x. I honestly couldn't remember how to do it in 9.8, but I found this in the 9.8 help file:
"

Let's say you added a button to the datagrid to export a single record. And if the record has been already exported (value of field exported equals 1), you want to hide the export button in this row.

  1. Switch to HTML mode in Visual Editor and add wrappers around button's code. Here is the sample code:
    {BEGIN MyButton}

    <A class="rnr-button button" id="MyButton" href="#" typeid="ib">

    MyButton

    </A>

    {END MyButton}
  2. Now in the List page: AfterRecordProcessed event add the following code:
    C#

    if (data["exported"] != 1)

    {

    record["MyButton"] = true;

    }
    This code will only display button if value of field exported equals 1.

    "
    Maybe this helps...?

    Tim

W
WebReports author 8/12/2020

Tim,
That was spot on. Working beautifully. Had to make a few tweeks on the Add/Edit javascript to show the blocks. Much thanks!



This is easy in 10.x. I honestly couldn't remember how to do it in 9.8, but I found this in the 9.8 help file:
"

Let's say you added a button to the datagrid to export a single record. And if the record has been already exported (value of field exported equals 1), you want to hide the export button in this row.

  1. Switch to HTML mode in Visual Editor and add wrappers around button's code. Here is the sample code:
    {BEGIN MyButton}

    <A class="rnr-button button" id="MyButton" href="#" typeid="ib">

    MyButton

    </A>

    {END MyButton}
  2. Now in the List page: AfterRecordProcessed event add the following code:
    C#

    if (data["exported"] != 1)

    {

    record["MyButton"] = true;

    }
    This code will only display button if value of field exported equals 1.

    "
    Maybe this helps...?

    Tim

W
WebReports author 8/13/2020

So, I have been trying for the last day on re-showing these fields when the user does an in-line edit or add to the list. I don't seem to be getting my fields to show up now.
I tried to add the following on the Add Page - Before Display:
xt.assign("field_vchar",true);

and

pageObject.setProxyValue("field_vchar",true);
In my HTML, I have:

{BEGIN field_vchar}

{$vchar_value}

{END field_vchar}

{BEGIN field_vint}

{$vint_value}

{END field_vint}


For my AddPage JavaScript, I was using the following before to switch between the two:



var ctrl = Runner.getControl(pageid, 'fieldid');

var vchar = Runner.getControl(pageid, 'vchar');

var vint = Runner.getControl(pageid, 'vint');
vchar.hidden=true;

vchar.hide();
vint.hidden=true;

vint.hide();
if(ctrl!=null) ctrl.on('change', func);
function func()

{

var fname = ctrl.getValue();
vchar.hidden=true;

vchar.hide();
vint.hidden=true;

vint.hide();
switch(fname)

{

Case 'text':

vchar.hidden=false;

vchar.show();

break;

}

}
D
drochel 9/7/2020

You may want to try selecting RESET in the Page Editor to restore the HTML for the page. This will allow you to check the fields that should be appearing on the page. You may occasionally experience problems with pages when you apply updates to the HTML. Just remember that you will need to re-apply your updates to the HTML after resetting the page but resetting the page may need to be done if any elements have gotten corrupted.
FYI - This article contains additional options for controlling the visibility of fields.

STORING FIELD LABELS AND VISIBILITY RULES IN THE DATABASE

H
heilmanmd 9/10/2020

Hello
Hidding fields on a page is easy peasy... honest...
I use JQUERY ( comes already installed with ASP Runner )
If you are not familiar with JQUERY, then it would be of great benefit to dive into it a bit...
Here is an example of how to do it using JQUERY in any of the Java Script Events...
take for instance you have a label span html code <span id="LABEL">Johnny go home</span>
and you want to hide it... then using JQUERY you'd to $('#LABEL').hide();
this is just the tip of the ice berg in using JQUERY ... I use it to trap an event say the save button on click to show / hide stuff all the time..
$('[id^="saveButton"]').on("click" function() {
yada yad code here...
});
better yet, say you have a hidden input field and want to populate it, or get the value of it, with Jquery it's a snap
heres the field
<INPUT name="deleteareg" id="deleteareg">
now to hide

$('[id^="deleteareg"]').hide();
then put something in it

$('[id^="deleteareg"]').val("HELLO WORLD");
then get something out of it

var hello_world = $('[id^="deleteareg"]').val();
Here is a link to JQUERY, if you are doing some serious projects, you can not live without it...
https://jquery.com
of course all of this assumes you are comfortable editing the page source in the various pages gen'd by ASP runner within the wizard...