Setting the default in a popup list in the edit modal popup?

(7 posts) (3 voices)

Tags:

No tags yet.

  1. adamhaeder, Member

    I have a report that I've added editing capabilities to. This report is basically just showing the entire contents of a mysql table (called 'child'), and allowing a user to edit the contents. One of the fields in the rows of this table is called 'parentid', and it refers to another table (called 'parent'). I need users to be able to change the parent that the child record is associated with, so I want to give them a drop down (popup in mydbr-speak) list of parents to pick from. That's fine, I have this all setup and it works.

    The problem is that when I edit an existing record, I'm using a parameter query to populate the 'popup' (drop down) list with all available parents, but the EXISTING parent id assigned to that record is not selected by default. So the problem I have is that if someone edits a child record in order to edit a different field (say, the 'notes' field for example), unless they specifically set the 'parent' dropdown back to what it's "supposed" to be, the dropdown is defaulting to the first entry that the parameter query returns.

    So my question is: knowing that I'm using a parameter query as the default selection for this field, how do I make it autoselect the existing value so I don't force my users to do this everytime they edit a record?

  2. myDBR Team, Key Master

    myDBR will select the correct value by default, no extra steps is necessary.

    It was bit unclear if you are using dbr.editable for the parentid column or edit multiple columns at the same time using dbr.report. Editing other fields when using dbr.editable should not affect other columns.

    In order to answer what might cause this for you, we would need to see the code / report.

    --
    myDBR Team

  3. michelles, Member

    I am having the same problem. I'm editing multiple columns at the same time using dbr.report and my popup lists are Country, Region, and City. I've connected these 3 parameters using the code here: http://mydbr.com/doc/content/start.userparam.html, but when I go to edit a row, the original selections aren't chosen.

  4. myDBR Team, Key Master

    Again, myDBR should select the correct value by default, no extra steps is necessary.

    In order se answer what might cause this for you, we would need to see the code / report.

    --
    myDBR Team

  5. adamhaeder, Member

    I figured mine out. My query looked something like this:


    SELECT
    a.id as "Child ID[childid]",
    a.childname as "Child Name[childname]",
    b.id as "Parent ID[parentid]",
    b.parentname as "Parent Name[parentname]"
    FROM childtable a
    LEFT JOIN parenttable b ON a.parentid = b.id;

    I wanted to edit the table in a modal popup, and have a drop down selection for all 'parentname' displayed. But each time I got the drop down, it just defaulted to the first listed parentname. I figured out it was because my code for the linked report looked like this:

    select 'dbr.report', 'sp_DBR_child_edit', 'inline', 'inID=childid', 'inParentname<=parentname';

    I was populating the inParentname variable with 'parentname' instead of 'parentid'. Once I fixed that:

    select 'dbr.report', 'sp_DBR_child_edit', 'inline', 'inID=childid', 'inParentname<=parentid';

    it worked. Then since I didn't want to actually display the ids in my report, I hid them:


    SELECT 'dbr.hidecolumn', 'childid';
    SELECT 'dbr.hidecolumn', 'parentid';

    Just put that code before your main select statement.

  6. myDBR Team, Key Master

    Adam,
    if your sp_DBR_child_edit report takes parentid as a paramerter, you might want to call it inParentID instead of inParentname. myDBR will convert the ID to name when a popup / radio button is attached to the parameter.

    --
    myDBR Team

  7. michelles, Member

    Thanks Adam! That did the trick!


Reply

You must log in to post.