8 Replies Latest reply on Aug 4, 2008 8:09 AM by Newsgroup_User

    Using a Variable for dataProvider Information

    Kurrykid Level 3
      I am trying to use a variable to populate the dataProvider for printing. I have pulled the example from the Flex 3: Training from the source book. When I try to use a variable, I get a Flash Player error stating that the provider is undefined. Does anyone know the correct way to type this so that it works?

      Here's the code:

      private function doPrint(event:Event):void{

      selection = event.currentTarget.id+"s.dataProvider"

      var pj:FlexPrintJob = new FlexPrintJob();

      if(pj.start() != true)

      var myPrintView:PrintView=new PrintView();
      myPrintView.myPrintDG.showHeaders = false;
      myPrintView.myPrintDG.rowHeight = 18;
      myPrintView.contact.text = "User Name: " + uname;
      myPrintView.myPrintDG.dataProvider = "(selection)";

      This line is the line I need to work: myPrintView.myPrintDG.dataProvider = "(selection)";

      If I replace "(selection)" with roles.dataProvider it works fine. I think it is just a syntax issue. If you look at the line above, I am using a variable for the User Name and that works fine.

      Any help would be greatly appreciated.