Javascript returned from the button stored proc

(3 posts) (2 voices)
  1. eugfri, Member

    hi,

    This is probably quite typical situation when button is added on the report and upon clicking, some database action has to be done as well as some screen update.
    So based on what some old threads mentioned, the right thing to do is probably to return javascript from the button report proc (like with your delete row example), but the question is how to access elements on the parent page from that javascript?

    Code from my prior post:


    SELECT 'dbr.button','CLEAR ALL';
    SELECT 'dbr.report', 'sp_DBR_SaveSerialsClearAll', 'inLogin=[inLogin]', 'cleared';
    SELECT 'dummy result set for the button'; SELECT 'dbr.hideheader';
    SELECT 'dbr.search', 0;
    SELECT 'dbr.hidecolumn', 'ID'; SELECT 'dbr.css', '.divtable { display:table; border:1px solid #666666;border-spacing:2px 2px;display:inline-block;empty-cells:show;width:402px; }';
    SELECT 'dbr.css', '.divrow { display:table-row;width:400px;clear:both; }';
    SELECT 'dbr.css', '.partnumber { float:left;display:table-cell;width:195px;border:1px solid black;padding:1px;height:13px;}';
    SELECT 'dbr.css', '.serialnum { float:left;display:table-cell;width:195px;border:1px solid black;padding:1px;height:13px;}'; SELECT 'dbr.divify', 'divtable';
    SELECT 'dbr.hidecolumns', 'divrow';
    SELECT 'dbr.rowclass', 'divrow'; SELECT 'dbr.record', 'begin', 'serialsrow'; SELECT 'dbr.editable', '[serialnum]', 'sp_DBR_SerialsScans_edit_serial', 'inID=[ID]', 'inSerialNum=[serialnum]', 'options={width:193,height:13}'; SELECT
    ID,
    ssn.GetName(partnumber,cond,ownership) AS partnumber,
    serialnum,
    'divrow'
    FROM ssn.partserialsstaging
    ORDER BY partnumber, cond, ownership, serialnum desc; SELECT 'dbr.record', 'end'; SELECT 'dbr.template', '#ScanSerialsDetails';
    SELECT "dummy"; SELECT 'dbr.button','SAVE';
    SELECT 'dbr.report', 'sp_DBR_SaveSerials', 'inLogin=[inLogin]', 'inTxType=(inTxType)', 'inTxnID=(inTxnID)', 'inTxnNumber=(inTxnNumber)', 'inRefNumber=(inRefNumber)', 'saved';
    SELECT 'dummy result set for the button'; SELECT 'dbr.embed_object', 'cleared';
    SELECT 'dbr.embed_object', 'saved';

    All I have in my sp_DBR_SaveSerialsClearAll is this:


    UPDATE ssn.partserialsstaging SET serialnum='';

    I would like to be able to clean up any entry in my editable field "serialnum" on the page - iterate through all rows and wipe whatever values are there.
    I tried dbr.refresh in my sp_DBR_SaveSerialsClearAll but it's not good for this situation.

    Thank you!

  2. myDBR Team, Key Master

    Eugfri,
    to apply a function to multiple cells, you can use jQuery.

    First, mark up the column whose values you want to clear.

    select 'dbr.colclass', 'serialnum', 'serialnum_col';

    In the button's report, return JavaScript to clear the data on the cells containing the class:

    select 'dbr.javascript', "$('.serialnum_col').text('');";

    --
    myDBR Team

  3. eugfri, Member

    Got it, works perfectly!


Reply

You must log in to post.