webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Copy contents of existing table row when firing an Add Row Button

  • 1.  Copy contents of existing table row when firing an Add Row Button

    Posted Tue June 11, 2013 01:25 PM

    I have a table where users fill in data in the different field columns. I added an Add Row Button at the end of each row and labeled it “Copy”. When user clicks it, I want the data from that row to be copied to the new row added.

    I’m not sure how to do it. Please help.

    Thanks.
    Anthony


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 2.  RE: Copy contents of existing table row when firing an Add Row Button

    Posted Tue June 11, 2013 08:00 PM

    None of the existing controls will do that automatically, but the CAF javascript API does have the necessary functionality to do that. See: http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_JavaScript_Reference/index.html

    You could use a generic ‘Output > Button’ control and write some custom javascript for the ‘Client-Side Events > Click’ control property that uses the CAF javascript APIs to add the row to the table.

    For example, the click script would look something like this:

    
    //get the row model object for the clicked row
    var rowId = $(this).up('tr').id;
    var rowModel = CAF.model(rowId);
    
    //get the table model object
    var tableId = $(this).up('table').id;
    var tableModel = CAF.model(tableId);
    
    //get the index of the current row
    var idx = tableModel.indexOf(rowModel);
    
    //add the row.  
    //  First arg is the index of the new row.
    //  Second arg is the CAF.Row.Model object to use to populate
    //     the values for new row.
    tableModel.add(idx, rowModel);

    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS