Results 1 to 11 of 11

Thread: MagicCell - how do I format this?

  1. #1
    Join Date
    Feb 2003
    Posts
    62

    MagicCell - how do I format this?

    Hi

    I want to be able to do 3 things with the MagicCell but I don't know how to combine the functions.

    My application has 6 columns which contain links to another page and passes parameters. That is straightforward enough and is working fine. At the moment the link text shows the content of each column using #field# in the anchor part of the macro. The fields concerned sometimes contain text and sometimes they don't.

    I want to be able to display the word `Result' if the field contains text and show an empty grid cell if it doesn't. If the text appears I want the link to go to a fixed .aspx page with parameters passed to it.

    In theory it should be something like:

    field 1 contains `Literacy1'.
    Show text `Result'. Link to page results.aspx?id=#id#

    Field 2 is empty.
    Show no text (don't link to anything)

    How can I do this?

    Thanks

    BobC

  2. #2
    Join Date
    Oct 2002
    Posts
    93
    Hi Bob,

    You should be able to use the MagicCell's "conditional" feature to accomplish this.

    It allows you to include an "if" check which outputs one set of info if true and another if false.

    See examples 2a, 2b, 2c, and 2d at:

    http://www.aspdbtest.com/examples/ep/default.asp

    Thanks,
    John

  3. #3
    Join Date
    Feb 2003
    Posts
    62

    MagicCell

    I am quite happy about getting the conditional part of this working. My problem comes with the syntax for combining this with the hyperlink. It is when I try to link both parts together that it doesn't work.

    How do I combine these together in the NWind sample:

    .dbGridMagicCell="field=shipCountry|macro=<A HREF=filtertest2.aspx?shipname=#(shipname)#&orderi d=#orderid#>#shipname#</A>"

    .dbGridMagicCell = "fi=shipCountry|Mac=(#shipCountry#|EQ|Brazil||RESU LT|)"

    By the way, I am using Tornado. The Classic samples are really good and I used to use them frequently when I was coding with asp. Why aren't they all converted to Tornado samples as well?

    Bob

  4. #4
    Join Date
    Oct 2002
    Posts
    933
    seems to me that the macro is a link <HREF...> and the result is the trigger. I do not thik this is possible. Magiccell evaluate the cell contents according to a pre-determined set of formats like #field# ...etc. Confirm this observation.


    FK

  5. #5
    Join Date
    Feb 2003
    Posts
    62

    MagicCell

    Hi

    MagicCell works fine for creating a link to another page passing parameters - I do it all the time, eg:

    .dbGridMagicCell = "field=details|macro=<A HREF=TestPage.aspx?region=#REGION# TARGET=NEW>ResultsA>!"

    AND I can get it to evaluate with no problem:
    .dbGridMagicCell="field=region|Macro=(#Region#|NB| ||RESULT~#REGION#"

    What I CAN'T do is combine them both.

    Bob

  6. #6
    Join Date
    Oct 2002
    Posts
    93
    Hi Bob,

    Well I hope you just cut/pasted wrong in your examples above because your HREF is missing the </A> tag, but anyway, it works fine.

    Here's an Nwind example that looks at the value in the Freight field in the Orders table. If the value is greater or equal to 32.19 then it makes it an <A HREF> tag, otherwise it displays the text "Less Than 32.19: #Freight#". Try it out and let us know.

    Thanks,
    John

    <script language="vb" runat="server">
    Sub Page_Load(Source as Object, E as EventArgs)
    Dim Grid1 As New Tornado.Z()
    with Grid1
    .dbQP = "s=1| ps=10| m=g| d=nwind.mdb| th=Title=Formatting and Modifying Cell| q=Select * from Orders| gdf=0,1,Freight"

    .dbGridMagicCell = "fi=Freight| Macro=(#Freight#|GEN|32.19||<a href='#Freight#'>#Freight#</a>~#Freight#|LTN|32.19||Less Than 32.19: #Freight#)"

    .ASPdbNet
    end with
    End Sub
    </script>

  7. #7
    Join Date
    Oct 2002
    Posts
    933
    Is that what it is?

    >...I want to be able to display the word `Result' if the field contains text and show an empty grid cell if it doesn't.

    You mean just test a field whetehr it is blank or with text?

    FK

  8. #8
    Join Date
    Feb 2003
    Posts
    62

    MagicCell

    Thanks John - you gave me enough clues to guess the answer!!

    My final MagicCell property looks like this (on employees table)

    .dbGridMagicCell = "fi=region| Macro=(#region#|NB|||<a href='filtertest2.aspx?region=#region#'>result</a>~#region#|NB|||result)"

    What this does is test the field region. If it is NOT blank, it shows the word `result' which is a hyperlink to the page filtertest2.aspx which is passed the parameter `#region#' (the value of the field `region'). I am still not quite sure WHY it works - can you give us an explanation of each part of the MagicCell line I have included?

    Thanks
    Bob

  9. #9
    Join Date
    Oct 2002
    Posts
    933
    how can you have a duplicated NB operator, shoud lit be a EL operator saying if NB then display the link ELSE display the word result??

    FK

  10. #10
    Join Date
    Feb 2003
    Posts
    62
    Frank

    That's was why I was asking for an explanation for each part of the macro.

    Bob

  11. #11
    Join Date
    Oct 2002
    Posts
    933
    The first test is NB and the second one should be "ELSE".

    FK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •