Custom dropdown list as filter

Dec 16, 2011 at 9:03 AM

Hi 

I have another question: 

Is it possible to create a custom dropdown list, based on a custom sql query, to filter the table data with an additional "where" clause?

 

best regards, 

Søren T

 

Coordinator
Dec 16, 2011 at 11:45 AM

Hi Søren,

Definitely. In the latest build (here on codeplex > downloads > latest build) you can you something like this:

      <field title="selfRefId" sourceField="selfRefId" umbracoDataType="Dewd Dropdown">
        <listControlDataSource includeEmpty="true" emptyValue="0">
          <sql><![CDATA[SELECT id, nvarcharField FROM dewdTypeTest WHERE id=@id]]></sql>
          <parameter name="@id" type="HttpContext" key="Request[id]" />
        </listControlDataSource>
      </field>

The parameter can be changed to point to a custom type, which returns the value or it can use one of the default parameter values as shown here:

<view name="Todays entries">
  <sql>SELECT * FROM umbracoLog WHERE CAST(Datestamp AS date)=@today</sql>
  <parameter name="@today" get="today" />
</view>

Hope this helps. I'll get back to your other question later, shouldn't be a problem either.

 

Dec 16, 2011 at 12:23 PM

Hi SuneBoegh

Thanks alot! Great news!:)

br, Søren T