2 Replies Latest reply: Oct 20, 2014 11:06 AM by jose taveras RSS

    Styling for the web.

    jose taveras

      Good afternoon,

      I've spent the good part of the week trying to publish a website containing QV objects. The reason I've dallied is because I haven't gotten access to the Objects' styles, and the current rendering of all textboxes features rows that are too small for the words inside them, which shows me words cut in half.

      I've found the Javascript API (rather recently) and I want to get some feedback about it's use as I see not too many people fidgeting with this issue.

      On the bottom of my body i have the following:

      <script type="text/javascript">

              var myDoc;

              Init = function () {

                  mydoc = Qv.GetCurrentDocument();

                  if (mydoc) { alert("Got Document"); } else { alert("Got Document"); }

                  // Test to see if I get the 'Document' which I'm still not sure what it's referring to. Right now there is no alert box popping out.

              }

              Qv.InitWorkBench(

                  {

                      View: 'COMEX',

                      BodyOnLoadFunctionNames: ['Init'],

                      InlineStyles:false

                  });

          </script>

      By setting the InlineStyles to false, I'm supposed to be able to override the QlikView Objects' default style, but this it doesn't seem to be responding that way.

      I tried adding a class to all my objects and placing the styling rules on the same page, and I tried adding inline styles (style="...") directly on each QlikView Object div.

       

      Any information would be greatly appreciated.

        • Re: Styling for the web.
          William Dib

          Hi Jose,

           

          Personally, I don't have much experience with QlikView's JavaScript API so I'll leave comments on that to the more experienced users. However, I can make a couple of comments about your JavaScript code:

           

          1. In JavaScript, variables are case-sensitive: myDoc and mydoc are not the same thing. You use a mix of these in the above code. Simply change all instances of mydoc to myDoc (or vice versa, although it's good practice to use camel case).

           

          2. Init isn't declared with the var keyword and the function expression doesn't end with a semi-colon nor does it have final parentheses or grouping operators. Also, your else code block is the same as the if one. So if the document exists, an alert box is supposed to say "Got Document" and, if it doesn't, you also get an alert box that says "Got Document". So how are you supposed to distinguish between the two? The else alert box should obviously say "No Document" or something like that. Here is what I believe that whole section should look like:

          1.PNG.png

          I hope this helps.

           

          Yours,

           

          William

            • Re: Styling for the web.
              jose taveras

              Thank you William.

              I am indeed fairly new to JS but I see these mistakes I made were a little trivial. I still don't fully understand closure, or the trailing parenthesis pair, but I'm seeing them more and more as I get examples of good code.

              Again, thanks.