Refresh field based on update of another field in different record of template

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


    I am using template and display number of fields on a form for user editing. However, based on changes made to one field I need to be able to update content of another field. However, they are not in one template record, but in different template records.
    Code snippet is below.
    In my sp_DBR_RMACustomerEmailPreview_edit_partnumber and sp_DBR_RMACustomerEmailPreview_edit_qty procedures I update value of EmailBody column in RMAEmailStaging table.
    I need somehow to force refresh value displayed in second record "body" inside of textarea.

    How would I go about it?

    SELECT 'dbr.record', 'begin', 'invoiceparts'; SELECT '', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.hidecolumn','ID'; SELECT 'dbr.editable', '[PartNumber]', 'sp_DBR_RMACustomerEmailPreview_edit_partnumber', 'inID=ID','inPartNumber=PartNumber'; SELECT 'dbr.editable', '[Qty]', 'sp_DBR_RMACustomerEmailPreview_edit_qty', 'inID=ID','inQty=Qty'; SELECT 'dbr.javascript', "function confirmdel(obj) {return confirm('Delete \\''+$(obj).parent().children().eq(1).text()+'\\'?');}"; SELECT '', 'sp_DBR_RMACustomerEmailPreview_del', '[del]', 'hiddendiv', 'inID=ID', 'inRefNumber=(inRefNumber)', 'event=click', 'callbefore=confirmdel'; SELECT 'dbr.purehtml:<div class="i_delete"></div>' as '[del]', ID, PartNumber, Qty FROM RMAEmailStaging WHERE SalesRep = inLogin; SELECT 'dbr.embed_object', 'hiddendiv'; SELECT 'dbr.record', 'end';

    SELECT 'dbr.record', 'begin', 'body'; SELECT '', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.colstyle', 'EmailBody', '[width:300px;height:144px;border:1px solid black]'; SELECT 'dbr.editable', '[EmailBody]', 'sp_DBR_RMACustomerEmailPreview_edit_body', 'inLogin=[inLogin]','inEmailBody=EmailBody', 'type=textarea', "options={'rows':20,'cols':50}"; SELECT EmailBody FROM RMAEmailStaging WHERE SalesRep = inLogin LIMIT 1; SELECT 'dbr.record', 'end';

    SELECT 'dbr.template', '#RMACustomerEmailPreview';

    SELECT "dummy";


    Thank you!

  2. myDBR Team, Key Master

    you can set a JavaScript class for the EmailBody, using dbr.resultclass and use that in sp_DBR_RMACustomerEmailPreview_edit_partnumber's callback to update the value from the database.

    myDBR Team

  3. eugfri, Member

    How would javascript function invoked from callback would have to look like to re-fetch value of EmailBody from the table?

  4. myDBR Team, Key Master

    When you return more than one value (columns) from the editing procedure the value returned to the callback returns an JSON string as first parameter containing the returned valued. You can then handle the individual values in in the callback.

    myDBR Team

  5. eugfri, Member

    Editing procs are usually just simple updates. So from my sp_DBR_RMACustomerEmailPreview_edit_qty I have to return EmailBody column value, so I can use it in the callback javascript function?
    Any small code sample would really help.
    Is this described anywhere in documentation ?

  6. myDBR Team, Key Master

    Editing procs can also return values.

    When an editing proc returns one value it is the value user entered formatted with cells format. If you do not use a callback you can use this to automatically format decimals to input data (user enters value without decimals and the returned value replaces the user input with formatted value (with decimals).

    When you use a callback function, the returned values will be passed in the first parameter to the callback. If you return more than one column, the first parameter returned will be a JSON string with all the values.

    Take a look at a editing example

    The editing procedure returns two columns ('value' & 'ascii'). The callback functions first parameter (value) will contain a JSON string (for example {"value":"B","ascii":"66"}") which you can convert to JavaScript object using jQuery.parseJSON.

    myDBR Team


You must log in to post.