Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Dec 06, 2011 @ 19:14
    Warren Buckley
    0

    Using the ID of current record your editing as a param for dropdown list

    Hi first off just used DEWD for the first time and I must admit it's a nice package if you want to work with custom DB tables inside Umbraco.

    I am trying to configure DEWD in the <editor> section of when editing a record in a table that one of the dropdown options it uses the ID from another table, which I have got to sucessfully to work.

    The problem I have now is that the list is BIG and for it to be more useful I want to be only to be able to select the items from the other DB table WHERE a field in that table matches the ID of the current record I am editing in DEWD. So this will enable the user to only select items from the other table as long as that one of the field from that record matches the ID.

    Hopefully this makes sense.

    This is the config snippet I have:

     

    <field title="Correct Answer" sourceField="CorrectAnswerID" umbracoDataType="Dewd Dropdown">
      <listControlDataSource includeEmpty="false">
        <sql><![CDATA[SELECT ID, Answer FROM [QuizAnswer] WHERE QuizQuestionID = @myCurrentID ORDER BY ID]]></sql>
      </listControlDataSource>
    </field>

     

  • Sune Bøegh 64 posts 374 karma points
    Dec 07, 2011 @ 09:54
    Sune Bøegh
    0

    Hi Warren,

    Thanks :) Shouldn't be a problem limiting the number of options based on the current ID. The listControlDataSource is actually supposed to support a (sql)parameter-subelement like the view, but looking into it, I can see that, that part is missing (soorry, my bad!) :( Now instead it's possible to override the implementation used on listControlDataSource instead, like this:

    <listControlDataSource type="MyNs.CustomListControlDataSource,App_Code" includeEmpty="false"> 
       <sql><![CDATA[SELECT ID, Answer FROM [QuizAnswer] WHERE QuizQuestionID = @myCurrentID ORDER BY ID]]></sql> 
    </listControlDataSource>

    Where MyNs.CustomListControlDataSource,App_Code is a class that implements the interface Eksponent.Dewd.Controls.IListControlDataSource, which consist of only one methods returning some ListItem(s).

    I will put together a IListControlDataSource that supports parameters later today and get back to you.

    - Sune

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Dec 07, 2011 @ 10:57
    Warren Buckley
    0

    Hey Sune,
    Thanks for the speedy response. Keep me posted on your progress.

    Cheers,
    Warren :) 

  • Sune Bøegh 64 posts 374 karma points
    Dec 07, 2011 @ 20:32
    Sune Bøegh
    0

    Hi Warren,

    I've made a little patch for you.

    If you download the latest build from codeplex at http://dewd.codeplex.com/releases/view/49197 and just replace the binary (Eksponent.Dewd.dll), you can do the following:
    <listControlDataSource includeEmpty="false">
        <sql><![CDATA[SELECT ID, Answer FROM [QuizAnswer] WHERE QuizQuestionID = @myCurrentID ORDER BY ID]]></sql>
        <parameter name="@myCurrentID" type="HttpContext" key="Request[id]" />
    </listControlDataSource>

    Hope this helps. If for some reason, you don't want to replace the binary, this is actually possible as well, it would just require a bit more configuration and some additional classes.

    - Sune

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Dec 07, 2011 @ 20:39
    Warren Buckley
    0

    Hi Sune,
    Thanks for such a fast fix however I worked on creating a custom section & trees today for a more polished UI, but I really appreciate your quick work on this and I think it will be a great addition to such a useful package.

    Keep up the great work.

    Cheers,
    Warren 

  • Sune Bøegh 64 posts 374 karma points
    Dec 07, 2011 @ 20:42
    Sune Bøegh
    0

    No prob. Happy coding :)

    - Sune

  • Sudipta Nandi 8 posts 27 karma points
    Feb 11, 2015 @ 20:02
    Sudipta Nandi
    0

    is this will be work for Umbraco 7.2.x

  • Sudipta Nandi 8 posts 27 karma points
    Feb 12, 2015 @ 16:17
    Sudipta Nandi
    0

    Dear Sune,

     

    Can you please provide me the class MyNs.CustomListControlDataSource

     

    Thanks

    Sudipta

Please Sign in or register to post replies

Write your reply to:

Draft