12 Replies Latest reply: Sep 24, 2011 3:38 AM by desperado RSS

    Setting the background color of a specific cell in table

      Hi All,

       

      I am new in Qlikview. I ran into the following.

      I developed a Qlikview document that opens a list of computers from a database.

      I want to ping the computernames and mark them as Present (green background) or Absent (red background), depending the result of the ping.

      The routine for pinging works OK.

       

      But I can't find a way to mark the cell red or green. I tried the doc's and API guide, but I can't find what I'm looking for.

       

      I pull in the data to a table. I can get the text from the field for the computer name.

       

      How do I set the background color for a cell from within a macro??

        • Setting the background color of a specific cell in table
          Stefan Wühl

          You run the ping in your load script? Do you use the result to set values in a tables field?

           

          If so, you might have a table like

           

          ComputerName, Alive

          Server1, 1

          Server2, 1

          Server3, 0

          ....

           

          For example, In a straight table you could use the visual cues to set the background colors depending on Alive Flag ( a table box misses that feature, I think).

           

          Create a straight chart, set ComputerName as dimension and Alive as expression.

          In Visual cues tab, set the upper and lower limits to 1 resp 0 and set the colors for text and background as you like.

           

          Hope this helps,

          Stefan

          • Setting the background color of a specific cell in table

            Seems I´m totally stuck here.

             

            I figured out how to make a straight table and I can add a field for the result of the ping.

            When I use SetInputFieldCell to set the content, when running the script, the script stops and shows the straight table with a grey cross in it and the script pops up. No errors, no results.

             

            Searching the Internet it looks like I must use an input field.

             

            I can´t figure out how to make an input field. I can declare it in the script, but it shows as a variable, not as a field.

             

            I´m using the free professional version, so examples won´t work.

              • Setting the background color of a specific cell in table
                Jason Michaelides

                Hi,

                 

                You may not be able to open our files but users of the full version can open yours so post your qvw and someone may be better placed to help. I'm not quite sure I follow what you're doing can you confirm I have understood the following correctly?

                 

                1. You load the computer names from a DB table but not the latest ping results.

                2. You are running a macro from within QV to ping the computers?

                 

                If I have understood you, you could do something like create a variable vResults and use the macro to write a delimited string of results to the variable. E.g. vResults = "computer1:1,computer2:0,computer3:1,computer4:1," (ensure final comma) etc. Then, in a straight table chart add ComputerName as the dimension and in the expression use the following:

                 

                =TextBetween(vResults,ComputerName & ':',',') to show the results in a nice table.

                 

                Then, in the background colour expression use:

                 

                IF(TextBetween(vResults,ComputerName & ':',',')=1,LightGreen(),Red())

                 

                Hope this helps,

                 

                Jason

                • Re: Setting the background color of a specific cell in table
                  Stefan Wühl

                  Hi desperado,

                   

                  I don't think you necessarily need an input field here, but maybe I misunderstood your problem.

                  Besides that, SetInputFieldCell is an automation interface member so how do you use it?

                   

                  Anyway, I think you could execute an (external) command script in the Qv script part to ping your machines. This script could (in a simple approach) just writes the results back to a file and this file could be read in by QV. I believe more fancy solutions without the need for the external file will also be possible.

                   

                  But since your original question was about highlighting the results in a specific table cell, I concentrated on this part ;-)

                   

                  So please have a look at my attached file.

                  - pscript.cmd is a simple batch file that pings machines and writes results back to a file (list of machines is read in from file iplist.txt).

                  - pingtest.qvw executes this batch file during load, then reads in the created file and voila - here you go with your results table

                  - in the QV document, I used an expression for the expression attribute background colour, to highlight the failed pings then (you could also use visual cues or some other formatting (text style, dimension name formatting,...)). I added some examples how to highlight.

                   

                  Hope this helps,

                  Stefan

                   

                  P.S:you might need to adjust the parse phrase "Lost" in the batch command file to your localized phrase for lost pings returned by your OS

                • Re: Setting the background color of a specific cell in table

                  Hi All,

                   

                  THX for replying.

                   

                  @Jason:

                  What I'm trying to accomplish is this. I want to use the report together with an asset management application. In the database I have a list of equipment details from computers, network equipment, printers etc (assets), including the name of the asset. I want to make a kind of dashboard with an overview of the equipment and I want to show if it is "alive" in the network.

                   

                  The list might be long, so pinging every asset on load time is (when I think about it) not desired because the load time can be long. I implemented a button with a macro (VBS) to perform the ping on demand. As desired a warning can be given that execution might take a while.

                   

                  So in the database tables is nothing like a ping result.

                   

                  I attached my current QV doc. It uses a plain table with the computer name, the OS version and the assigned user. Nothing fancy.

                  And the macro returns an error on inserting the text in the table.

                   

                  Thanks in advance,

                  Mario

                    • Re: Setting the background color of a specific cell in table
                      Stefan Wühl

                      Hi Mario,

                       

                      I think the main problem is to use string input fields in a table chart. This is not possible as far as I know, because you have to use inputsum / inputavg in a table chart. But you can use string input fields in a table box / list box, and that's what I did (and the table chart will be updated accordingly).

                       

                      Then I added a Inputfield declaration in the script, I think that was missing, too.

                       

                      The rest is mostly using your code (I changed a little bit the index calculations, but just playing around).

                       

                      Have a look and see if this will fit your needs.

                       

                      Stefan

                       

                      P.S.

                      I think the input fields solution will be per user, i.e. each user has to call the macro to see the results. So if you have a lot of users, it might still be better to think about a periodically called Alive-Check, writing the results back somewhere and use a server reload to just update the alive values.

                    • Re: Setting the background color of a specific cell in table

                      No, not yet.

                      Due to holidays the project takes more time.