EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  if CheckBox is checked call function

    Posted Fri March 20, 2015 04:25 AM

    Hello,

    Here' s my code  about a datagrid with checkboxes.

    I need to implement a function to call every time I check a box. How is this possible?

    Thanks!

    michaeldefox


  • 2.  Re: if CheckBox is checked call function

    Posted Fri March 20, 2015 07:53 AM

    Hi,

    you could try it with the EditorBehaviors like this:

     

        function EditorBehaviors(grid DataGrid in, cell Widget in, rowData any in, rowIndex int in, column DataGridColumn in, value any in) returns(Widget)
            case(column.name)
                when("KOX")
                    KOX_CHECK DojoCheckBox{text = "", selected = false, disabled = false, onClick ::= KOX_CHECK_OnClick_do_what_you_want};

                    if(rowData.KOX as string == "X")
                        KOX_CHECK.selected = true;
                    end
                    cell.children =[KOX_CHECK];

            end
        end

    Marcel-D


  • 3.  Re: if CheckBox is checked call function

    Posted Fri March 20, 2015 09:48 AM

    I want the event function  to run only if I check every checkBox . 

    I have added showCheckBoxes = true in datagrid and the checkboxes have already been created so I don't want to use  case column.name.

    Is there any flag in widget's egl file that determines the time I click checkBox like checked=true  or something else?

    michaeldefox


  • 4.  Re: if CheckBox is checked call function

    Posted Mon March 23, 2015 05:58 AM

    You could consider using the Datagrid's checkboxListener, which is fired every time a checkbox is (un)selected. Every time you (un)select a checkbox you will be able to retrieve a list of all selected rows (datagrid.checked()). So you will have no direct indication of what row is (un)selected. You would have to keep a list of selected rows outside of the datagrid to be able to determine what new checkbox was selected.

    gweis


  • 5.  Re: if CheckBox is checked call function

    Posted Tue March 24, 2015 03:21 AM

    I 'm trying this function and I call it in datagrid as selectionListeners =[myListener] but I  see which checkbox is selected only when I select the row. I want to see it when I check each box instead. Could you help me find it?  And another issue is if there is a way to return a value from mylistener function to use it in another function of the program. Thanks

    function myListener(grid DataGrid in)
     sysLib.writeStdOut( "in listener"); 
     
    columnRetrieve Rec[]; 
    columnRetrieve = grid.getChecked() as Rec[]; 
    numberOfRows int = columnRetrieve.getSize();
     sysLib.writeStdOut( "number of rows: " + numberOfRows); 
     if(numberOfRows > 0) 
       for(i int from 1 to numberOfRows)
        sysLib.writeStdOut(columnRetrieve[i].name + " is selected."); 
        end
     end
     end
    michaeldefox


  • 6.  Re: if CheckBox is checked call function

    Posted Tue March 24, 2015 06:52 AM

    You shouldn't use the Datagrid's selectionListener. Use the checkboxListener instead.
    I expanded your sample code and now functions as you described.
    By the way: In my opinion Marcel's solution is more elegant and doesn't require the extra code as I have put in function checkboxListener.

    Regards,
    Guus

     

    gweis


  • 7.  Re: if CheckBox is checked call function

    Posted Fri April 24, 2015 09:12 AM

    Why do you use the name of column "field1" ? 

    How can I retrieve only the number of row which is selected?

    Is it possible to change  function checkboxListener (grid DataGrid in) somehow to return the line of the box which is checked?

    michaeldefox