Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
11 replies Latest Post - ‏2012-12-17T10:08:33Z by SystemAdmin
SystemAdmin
SystemAdmin
7615 Posts
ACCEPTED ANSWER

Pinned topic Set button onclick V8

‏2012-12-11T14:40:17Z |
Hi everyone,

Let's get to the point that bring me here.
I'm using v8.0.1 and I want to set a button's click event that resides in a table's cell element. I have seen several options but so far none of them as achieved the objective.

So in last try I made this:
dojo.query(' button').connect('click', function(e){alert(true);});

I can get all the pretended buttons, but I cannot set the onclick such that if I do:
alert(dojo.query(' button')[0].click)

Only gives me the native function.

So, what am I doing wrong?

Any help would be appreciated.

Best regards,
VF
Updated on 2012-12-17T10:08:33Z at 2012-12-17T10:08:33Z by SystemAdmin
  • kolban
    kolban
    3315 Posts
    ACCEPTED ANSWER

    Re: Set button onclick V8

    ‏2012-12-11T16:35:18Z  in response to SystemAdmin
    Are you using the new v8 Coach View based coaches or the heritage (pre v8) coaches?

    I think it would really help if you could describe what effect it is you are trying to achieve and more details of the environment.

    For example:

    o When you say a button ... do you mean a button YOU added to the page or an IBM Coach View button?
    o When you say a table cell ... do you mean a table you coded in HTML, the use of an IBM Coach View table or a Dojo DataGrid that you built?

    Neil
    • SystemAdmin
      SystemAdmin
      7615 Posts
      ACCEPTED ANSWER

      Re: Set button onclick V8

      ‏2012-12-11T17:06:04Z  in response to kolban
      Hi Neil,

      I'm using the V8 coach view based and every controls used are product controls.
      In the table I have n-columns and one more column where in every cell reside a button. (Note that this button isn't binded to any variable)

      What I want to accomplish is, set the button's onclick event, to do something (Ex: show the table's row index). But I wasn't be able to do that.

      I guess this is all but if isn't enough, I'm here.

      Best regards,
      VF
      • SystemAdmin
        SystemAdmin
        7615 Posts
        ACCEPTED ANSWER

        Re: Set button onclick V8

        ‏2012-12-12T02:31:14Z  in response to SystemAdmin
        Hi,

        In the earlier reply I forgot to provide one information that I consider important.
        The table resides in a Coach View, fact that could restrict the answer.

        Thank you, I will await for yours answers,
        VF
      • kolban
        kolban
        3315 Posts
        ACCEPTED ANSWER

        Re: Set button onclick V8

        ‏2012-12-12T04:17:45Z  in response to SystemAdmin
        So I am imaging a Coach Table with a set of columns and a last column (for example) that contains "Buttons". Ok ... so far so good. Now comes the puzzle ... what is the semantic of pressing the button? What is it we want to happen?

        In your story, you describe firing the button's "onClick" event. But it is what you are not saying that is interesting here. It sounds like you want to code some JavaScript and have that JavaScript triggered as a result of the button press. This you can achieve ... but you have to follow IBM's model.

        A Coach View is a container for both visual display (HTML) and logic (JavaScript) that conforms to the IBM Coach View architecture (lifecycle). If you want custom logic executed, the "correct" way to do that is to build a Coach View. But let us put this to one side for a moment. What is it you actually want the button press to "do"? What is your functional end goal?

        Maybe you don't have one ... and are at this time studying the Coach technology ... the answer there is to study Coach View technology ... but if you do have an end goal ... do you know what it might be? What is it you want the button press to achieve?

        Neil
        • SystemAdmin
          SystemAdmin
          7615 Posts
          ACCEPTED ANSWER

          Re: Set button onclick V8

          ‏2012-12-12T11:39:18Z  in response to kolban
          Hi d_petkoff and Neil,

          @d_petkoff
          You were right about your tip. That one of the problems that I faced, because it was a bad user experience behaviour, so I set "disable click to edit" option to true earlier.

          @Neil
          My end goal is to return the table's row index or get the collection's element binded to that table's row.
          Can you give references to "IBM Coach View architecture" and "Coach technology"?

          Thank you, best regards,

          VF
          • kolban
            kolban
            3315 Posts
            ACCEPTED ANSWER

            Re: Set button onclick V8

            ‏2012-12-12T16:52:48Z  in response to SystemAdmin
            I was going to point you to a great article in the forum that appeared just the other day:

            https://www.ibm.com/developerworks/forums/thread.jspa?threadID=464624&tstart=0

            And then I realized you wrote the article :-)

            In your last post you said:

            "My end goal is to return the table's row index or get the collection's element bound to that table's row."

            If I understand what you are saying ....

            "I have a table that contains a set of rows where each row corresponds to an individual record of data. When the table is displayed to the user, I wish to allow the user to select a row of data. My desire is to provide a 'button' at the end of each row of data such that when the button is pressed, that will be the indication that the row has been selected. Since I understand Coach View technology, what I want to happen is that when the button is pressed, a boundary trigger must occur that returns control back to my Human Service implementation. A variable will also have been updated prior to the boundary trigger such that my Human Service will know which row was selected."

            Is this a summary of what you are asking for?

            Neil
            • SystemAdmin
              SystemAdmin
              7615 Posts
              ACCEPTED ANSWER

              Re: Set button onclick V8

              ‏2012-12-12T23:33:19Z  in response to kolban
              Hi Neil,

              That's the summary of what I want to accomplish.
              The problem resides in the fact that, first, I can not set the onclick event, and second, I need to return the row index.

              Best regards,
              VF
              • kolban
                kolban
                3315 Posts
                ACCEPTED ANSWER

                Re: Set button onclick V8

                ‏2012-12-13T05:40:50Z  in response to SystemAdmin
                One of the first things I tried was building a table with a Button as the last column. I was surprised to find that the button was "disabled". As I thought about this some more, I think I realized that Coach Views in a cell are "read-only" until the cell is clicked. This seems to mean that a simple button isn't going to "cut it".... :-)

                Neil
                • kolban
                  kolban
                  3315 Posts
                  ACCEPTED ANSWER

                  Re: Set button onclick V8

                  ‏2012-12-13T06:01:49Z  in response to kolban
                  I did find a solution which seems to work and is pretty elegant.

                  I wrote a new CoachView called "Table Button". This Coach View manifests itself as a visible button. I defined the allowable bound into type as "ANY" and hence it can be bound to any type of variable. I defined the handler for the event called "click" to invoke a function ... and the function performs a CoachView Trigger to trigger a call back to the Human Service. But here is the cool thing ... and I think this is new in 8.0.1 ... I found that when I added my Table Button as the last column in the table, I was able to bind the button to the variable called "bo1.currentItem". Now ... "bo1" is a list of "BO1" Data Types (my own data type). But what is interesting is that because "bo1" is a list, it appears to have a meta property called "currentItem". When I bind my button to "bo1.currentItem" as opposed to "bo1.currentItem.fieldName" I get a handle to the whole "current" Business Object for the row when I execute:

                  
                  this.context.binding.get(
                  "value")
                  


                  The bottom line is that all the parts seem to be present and all that remains is "some assembly". I wouldn't even suggest starting this project without a good grasp of JavaScript, Dojo and ... especially ... the CoachView architecture.

                  I get the distinct impression from the "out of the box" table handling is that one is supposed to associate a table with a list and, separately, have a "button". One would then select a row in the table and, after selection, press a button. When the button fires its trigger back to the Human Service, the bound list indicates what the current selection may be. With this model, no coding or new Coach Views are required and you get the function "for free".

                  Neil
  • d_petkoff
    d_petkoff
    13 Posts
    ACCEPTED ANSWER

    Re: Set button onclick V8

    ‏2012-12-12T08:40:48Z  in response to SystemAdmin
    Hi,
    there is a small trick with stock tables and buttons :
    check the table's configuration option "disable click to edit".
    If this config is set to false, then you first have to click on the table cell to make it active, then you can click your button. This might be your problem.

    Regards,
    D.