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:
<fieldtitle="Correct Answer"sourceField="CorrectAnswerID"umbracoDataType="Dewd Dropdown"><listControlDataSourceincludeEmpty="false"> <sql><![CDATA[SELECT ID, Answer FROM [QuizAnswer] WHERE QuizQuestionID = @myCurrentID ORDER BY ID]]></sql> </listControlDataSource></field>
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.
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.
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.
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:
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
Hey Sune,
Thanks for the speedy response. Keep me posted on your progress.
Cheers,
Warren :)
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
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
No prob. Happy coding :)
- Sune
is this will be work for Umbraco 7.2.x
Dear Sune,
Can you please provide me the class MyNs.CustomListControlDataSource
Thanks
Sudipta
is working on a reply...