mv database and displaying in Zen Web page

8 views
Skip to first unread message

Sam Kidd

unread,
Sep 28, 2012, 11:21:54 AM9/28/12
to InterSy...@googlegroups.com
Hi, I'm fairly new to Cache and come from a Pick background but we have now transferred our databases into Cache and they are sitting in Globals. But i wanted to create a web site using Zen to view and update one of my Pick files (databases) and therefore have used PROTOCLASS to create a class within the MVFILE project (? - sorry probably using all the wrong terminology!!).
 
Now i have followed the tutorial in the multi-value section and have created my web page with my mv database. But am trying to understand how to extract data from a multi-value field in the database and create a sort of Query on the file.
 
Basically, i have a table that lists data from a file with attributes ID, Name, Password and Access Level.  It is the Access Level that holds multi-value data such as "A B I C" and i want to create a "subroutine" to say search the field and locate an "A" within the field and if you can find one, display Web Page 1.  I am just a little unsure about how to do this. I have tried  do this with a javascript class which starts the check of the file:
 
ClientMethod StartCheck() [ Language = javascript ]
{
  var ok true;

  if (zenPage.Checkmyagent("EE")!=1) ok false;
  if (ok == true) alert(zenText('True'));
  else alert(zenText('False'));
  
  return;
}
but you can see, that i had to put in an actual item ID above ("EE") as i have no idea how to obtain the item ID from the javascript table listed on the web page. 
 
i then do the check using mvbasic:

Method Checkmyagent(pID As %String) As %String [ Language = mvbasic, ZenMethod ]
{
IVAL=0
OPEN "FP.AGENTS" TO AGENTS THEN
     READ AGVAR FROM AGENTS,pID THEN
      AGVAR31=AGVAR<31>
      VMCOUNT = DCOUNT(AGVAR31,@VM)
          FOR I = 1 TO VMCOUNT UNTIL IVAL EQ 1
            IF AGVAR31<1,I> = "A" THEN IVAL=1
           NEXT I
        END
    END   
    RETURN IVAL
}

Does this make any sense??!!
 
Can anyone help?
 
Thank you!
Regards,
Sam
 

Jason Warner

unread,
Sep 28, 2012, 12:45:44 PM9/28/12
to intersy...@googlegroups.com
Sam,

I am making some assumptions here, so please correct me if they are
wrong.

1. You are using the zen tablePane to display your information.
2. Your tablePane includes the columns ID, Name, Password and
AccessLevel

In javascript, you can get the tablePane object by using
zen("tablePaneID"). From there, you can access rows and from the rows,
you can get values of specific columns. However, this may not be what
you want. For example, if you want to only display items with the "A"
access level, you could write your own class query that will let you
pick an access level and then return only the rows with that access
level. This class query can then be wired up to the tablePane in the
query.

If you want to be able to click on an item and then run your checks,
you can set the valueColumn parameter of the tablePane to your "ID"
column. Then in your click handler, you can get the ID of the selected
row with this code zen("tablePaneID").getValue().

These could all be wrong because of my assumptions, but hopefully they
give you ideas. Also, your StartCheck() method can be simplified to:

if (zenPage.Checkmyagent("EE") ==1 )
alert(zenText('True'));
else
alert(zenText('False'));

or even more compact would be to change the return type of
Checkmyagent() to %Boolean and then you can do:

alert(zenPage.Checkmyagent("EE"));

or alternatively for branching based on the permission:

if (zenPage.Checkmyagent("EE")) {
}
else {
}

Jason
> --
> You received this message because you are subscribed to the Google
> Groups "InterSystems: MV Community" group.
> To post to this group, send email to Cac...@googlegroups.com
> To unsubscribe from this group, send email to
> CacheMV-u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/CacheMV?hl=en
Reply all
Reply to author
Forward
0 new messages