Partial screen refresh - set one editable field with value of another

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

    Hi,

    Refresh of part of the report, or refresh of one field seems to be a previously covered topic. I tried to follow this thread but without success:
    https://mydbr.com/forums/topic.php?id=1950#post-5593
    I have couple of scenarios I am trying to handle:
    1) Two editable fields. One is selection from the dropdown, second one - simple textbox. How can I make second field to reflect same value that's been selected from dropdown in the first field?
    Have been trying various things with callback, but no luck.

    2) Displayed resulset and two more editable text fields on the same report. Depending on the row user clicks on - I would like to populate two editable text fields with values of the first two columns of the resultset row user clicked on.
    I have tried to use extra column (similar to "delete" column in your examples of editable report) with the callback function. I can access the values I need from my result set but I don't know how to set values of my textboxes to them.

    Would really appreciate your suggestions or some sample code.

    Thank you

    Eugene

  2. myDBR Team, Key Master

    Eugene,
    your question did not include any details/sample code, but you use callbacks in both cases. Use JavsScript to get the result value from callback and use jQuery to set the value. Easiest is to add a class to the field whose value you wish to change:

    $('.resultfield').text(value);

    --
    myDBR Team

  3. eugfri, Member

    sorry, I should have put in some of my code here.
    There it its:

    SELECT 'dbr.record', 'begin', 'newcompanyname'; SELECT 'dbr.purehtml','<p>Create new:</p><div id="new">'; SELECT 'dbr.search', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.colstyle', 'CompanyName', '[width:300px;height:20px;border:1px solid black]'; SELECT 'dbr.editable', '[CompanyName]', 'sp_DBR_ReviewQuote_edit_customer', 'inLogin=[inLogin]','inCompanyName=CompanyName'; SELECT CompanyName FROM ssn.QuoteStaging WHERE SalesRep = inLogin LIMIT 1; SELECT 'dbr.purehtml','</div>'; SELECT 'dbr.record', 'end';

    SELECT 'dbr.record', 'begin', 'existingcompanyname'; SELECT 'dbr.purehtml','<p>Or select from list:</p><div id="existing">'; SELECT 'dbr.search', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.colstyle', 'CompanyName', '[width:300px;height:20px;border:1px solid black]'; SELECT 'dbr.editable', '[CompanyName]', 'sp_DBR_ReviewQuote_edit_customer', 'inLogin=[inLogin]','inCompanyName=CompanyName', 'type=select', "select=SELECT ' ' AS CompanyName UNION SELECT CompanyName from Customer", "options={'callback':selCompanyName}"; SELECT CompanyName FROM ssn.QuoteStaging WHERE SalesRep = inLogin LIMIT 1; SELECT 'dbr.purehtml','</div>'; SELECT 'dbr.record', 'end';

    I am using template and hence recording #newcompanyname and #existingcompanyname to be placed on the template. I need to make #existingcompanyname a value picked from drop down list and whatever value is picked, I want to set it on #newcompanyname.

    So what would be the syntax to use in my callback selCompanyName function?

  4. myDBR Team, Key Master

    Eugene,
    first add a class to the first editable field so you can access it directly.

    select 'dbr.colclass', 'CompanyName', 'createnew_td';

    Your 'selCompanyName'-callback will return the selected CompanyName, so you set the value with JavaScript:

    select 'dbr.javascript', 'function selCompanyName(company)
    {
    $(".createnew_td").text(company);
    }';

    --
    myDBR Team

  5. myDBR Team, Key Master

    Eugene,
    first add a class to the first editable field so you can access it directly.

    select 'dbr.colclass', 'CompanyName', 'createnew_td';

    Your 'selCompanyName'-callback will return the selected CompanyName, so you set the value with JavaScript:

    select 'dbr.javascript', 'function selCompanyName(company)
    {
    $(".createnew_td").text(company);
    }';

    --
    myDBR Team

  6. eugfri, Member

    Great! This works perfectly!
    Another case is when I have editable field selected from dropdown and I would like to have another resultset displayed on the page which is using value selected in dropdown in the WHERE clause.
    I.e. depending on value selected in dropdown I would like to be able to refresh resultset.
    Is that possible to accomplish via Jquery and callback?

    SELECT 'dbr.record', 'begin', 'existingcompanyname'; SELECT 'dbr.purehtml','<p>Or select from list:</p>'; SELECT 'dbr.search', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.colstyle', 'CompanyName', '[width:300px;height:20px;border:1px solid black]'; SELECT 'dbr.editable', '[CompanyName]', 'sp_DBR_ReviewQuote_edit_customer', 'inLogin=[inLogin]','inCompanyName=CompanyName', 'type=select', "select=SELECT ' ' AS CompanyName UNION SELECT CompanyName from ssn.Customer", "options={'callback':selCompanyName}"; SELECT CompanyName FROM ssn.QuoteStaging WHERE SalesRep = inLogin LIMIT 1; SELECT 'dbr.record', 'end';

    SELECT 'dbr.record', 'begin', 'existingcontact'; SELECT 'dbr.search', 0; SELECT 'dbr.hideheader'; SELECT 'dbr.hidecolumn', 'ID'; SELECT 'dbr.hidecolumn', 'ContactID'; SELECT 'dbr.report', 'sp_DBR_ReviewQuote_selcontact', '[sel]', 'hiddendiv', 'inID=ID', 'event=click', 'callbefore=selContact'; SELECT CompanyName INTO vCompanyName FROM ssn.QuoteStaging WHERE SalesRep = inLogin LIMIT 1; SELECT 'dbr.purehtml:<div class="i_info"></div>' as '[sel]',ID, ContactID, FirstName, LastName, JobTitle AS Role FROM ssn.contact WHERE companyname=vCompanyName; SELECT 'dbr.embed_object', 'hiddendiv'; SELECT 'dbr.record', 'end';

    So in the query from ssn.contact table I would like to be able to use in WHERE value selected from the dropdown in the #existingcompanyname so my resultset would update dynamically. Currently I am just fetching vCompanyName so at least I get desired result on the screen load but that is not good enough.

    Thank you!

  7. myDBR Team, Key Master

    The editable fields are meant for editing purposes. If you just want to display a selectlist and another resultset based on the selections, much easier way is to use dbr.selectlist:

    select 'dbr.report', 'sp_DBR_car_models', 'details[]', 'in_id=id';
    select 'dbr.selectlist'; SELECT name, id
    FROM car_manufacturers;

    --
    myDBR Team

  8. eugfri, Member

    But I need to do db update upon user selection from dropdown list as well. Not only be able to change resultset display

  9. myDBR Team, Key Master

    You can do the update in the linked report in addition it returning the result set.

    --
    myDBR Team

  10. eugfri, Member

    yes, but if I use dbr.selectlist in order for it to show any values I have to attach report to it. It does not show values otherwise. But if I attach report to it (let's say table update), as soon as I select value from the list, report is invoked and it is shown instead of the original screen with selectlist.

    I am just trying to have selectlist displayed and based on selected value to have resultset displayed under it.

  11. myDBR Team, Key Master

    Eugene,
    if you specify the target where the selectlist's attached report is shown then you should get exactly the thing you are looking for. The resultset based on user selection is shown inside the main report in a location you specify.

    In the example we gave, the 'details[]' parameter is the target parameter (target DIV). If you want to place the DIV in specific location, you can create an empty DIV by yourself. The '[]' at the end of target DIV name will make the DIV dynamic (myDBR will create the DIV if it does not exists.

    See an example.

    --
    myDBR Team


Reply

You must log in to post.